mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Compare commits
38 Commits
CR32811_1
...
IR-2022-04
Author | SHA1 | Date | |
---|---|---|---|
|
7021de2fe7 | ||
|
e455c54bf0 | ||
|
d31e5dbbb4 | ||
|
878ea8cd2b | ||
|
ee6581adbe | ||
|
1fff4ad5a7 | ||
|
a793b75e21 | ||
|
5078d0d84e | ||
|
ad3825f821 | ||
|
fe12f15cb4 | ||
|
b2ec2f5d42 | ||
|
e3fd3d83da | ||
|
1f37f1d50a | ||
|
1f000e5974 | ||
|
2491eec38b | ||
|
ab279b126b | ||
|
e4753a7d16 | ||
|
5ae6f08cc6 | ||
|
9b337ad8e5 | ||
|
3425e83f4b | ||
|
e720157864 | ||
|
452ba192d5 | ||
|
9140163ba8 | ||
|
7573a45deb | ||
|
802180e1a5 | ||
|
8ca58a51a7 | ||
|
acce2c1448 | ||
|
633084b809 | ||
|
a9e5f65041 | ||
|
b9a372bbcd | ||
|
b5204c6c37 | ||
|
75e2ba1695 | ||
|
5c48956f8e | ||
|
b9184c2714 | ||
|
e61aa824db | ||
|
5a846a5d2c | ||
|
b91e601442 | ||
|
cfde7eebb3 |
@@ -56,6 +56,20 @@ set_property (GLOBAL PROPERTY OCC_VERSION_MAJOR ${OCC_VERSION_MAJOR})
|
||||
set_property (GLOBAL PROPERTY OCC_VERSION_MINOR ${OCC_VERSION_MINOR})
|
||||
set_property (GLOBAL PROPERTY OCC_VERSION_MAINTENANCE ${OCC_VERSION_MAINTENANCE})
|
||||
|
||||
# set soversion variable determining compatibility version on platforms with symlinks
|
||||
# 0 - for empty, 1 - for major, 2 - for major.minor, 3 - for major.minor.maintenance
|
||||
if (NOT BUILD_SOVERSION_NUMBERS)
|
||||
set (BUILD_SOVERSION_NUMBERS "0" CACHE STRING "${BUILD_SOVERSION_NUMBERS_DESCR}" FORCE)
|
||||
SET_PROPERTY(CACHE BUILD_SOVERSION_NUMBERS PROPERTY STRINGS 0 1 2 3)
|
||||
|
||||
# update default state of soversion on different platforms
|
||||
if (WIN32 OR ANDROID OR EMSCRIPTEN)
|
||||
set (BUILD_SOVERSION_NUMBERS 0)
|
||||
else()
|
||||
set (BUILD_SOVERSION_NUMBERS 2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set (INSTALL_TEST_CASES OFF CACHE BOOL "${INSTALL_TEST_CASES_DESCR}")
|
||||
|
||||
# Regeneration of OCCT resource files
|
||||
@@ -1225,7 +1239,7 @@ foreach (OCCT_CONFIGURATION ${CMAKE_CONFIGURATION_TYPES})
|
||||
endforeach()
|
||||
# install OpenCASCADE config file with compile definitions and C/C++ flags ONLY for current configuration
|
||||
install (CODE "string (TOLOWER \"\${CMAKE_INSTALL_CONFIG_NAME}\" CMAKE_INSTALL_CONFIG_NAME_LOWER)")
|
||||
install (CODE "configure_file(\"${CMAKE_BINARY_DIR}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" \"${INSTALL_DIR}/${INSTALL_DIR_CMAKE}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" COPYONLY)")
|
||||
install (CODE "file(INSTALL FILES \"${CMAKE_BINARY_DIR}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" DESTINATION \"${INSTALL_DIR}/${INSTALL_DIR_CMAKE}/\" TYPE FILE)")
|
||||
|
||||
foreach (OCCT_MODULE ${OCCT_MODULES})
|
||||
if (BUILD_MODULE_${OCCT_MODULE})
|
||||
|
@@ -280,14 +280,17 @@ get_property (OCC_VERSION_MAJOR GLOBAL PROPERTY OCC_VERSION_MAJOR)
|
||||
get_property (OCC_VERSION_MINOR GLOBAL PROPERTY OCC_VERSION_MINOR)
|
||||
get_property (OCC_VERSION_MAINTENANCE GLOBAL PROPERTY OCC_VERSION_MAINTENANCE)
|
||||
|
||||
if (ANDROID)
|
||||
# do not append version to the filename
|
||||
set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}")
|
||||
else()
|
||||
set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}"
|
||||
SOVERSION "${OCC_VERSION_MAJOR}"
|
||||
VERSION "${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}")
|
||||
set (OCC_SOVERSION "")
|
||||
if (BUILD_SOVERSION_NUMBERS GREATER 2)
|
||||
set (OCC_SOVERSION "${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}")
|
||||
elseif (BUILD_SOVERSION_NUMBERS GREATER 1)
|
||||
set (OCC_SOVERSION "${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}")
|
||||
elseif (BUILD_SOVERSION_NUMBERS GREATER 0)
|
||||
set (OCC_SOVERSION "${OCC_VERSION_MAJOR}")
|
||||
endif()
|
||||
set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}"
|
||||
SOVERSION "${OCC_SOVERSION}"
|
||||
VERSION "${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}")
|
||||
|
||||
set (USED_TOOLKITS_BY_CURRENT_PROJECT)
|
||||
set (USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT)
|
||||
|
@@ -28,6 +28,9 @@ Applies only for Debug configuration.")
|
||||
set (BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR
|
||||
"Append the postfix to names of output libraries")
|
||||
|
||||
set (BUILD_SOVERSION_NUMBERS_DESCR
|
||||
"Version numbers to put into SONAME: 0 - for empty, 1 - for major, 2 - for major.minor, 3 - for major.minor.maintenance")
|
||||
|
||||
set (BUILD_RELEASE_DISABLE_EXCEPTIONS_DESCR
|
||||
"Disables exceptions like Standard_OutOfRange in Release builds.
|
||||
Defines No_Exception macros for Release builds when enabled (default).
|
||||
|
@@ -132,21 +132,31 @@ for (aPackage, aPackages) {
|
||||
}
|
||||
}
|
||||
|
||||
# extend clean with versioned .so files
|
||||
!win32 {
|
||||
aVerList = $$split(VERSION, ".")
|
||||
aVerMaj = $$member(aVerList, 0)
|
||||
aVerMin = $$member(aVerList, 1)
|
||||
aVerMic = $$member(aVerList, 2)
|
||||
|
||||
equals(TEMPLATE, app) {
|
||||
QMAKE_CLEAN += $$DESTDIR/$${TARGET}
|
||||
} else {
|
||||
mac {
|
||||
# override qmake soname versionong logic
|
||||
QMAKE_LFLAGS_SONAME =
|
||||
QMAKE_LFLAGS += -Wl,-soname=lib$${TARGET}.dylib.$${aVerMaj}.$${aVerMin}
|
||||
|
||||
# extend clean with versioned .dylib files
|
||||
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.dylib
|
||||
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.$${aVerMaj}.dylib
|
||||
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.$${aVerMaj}.$${aVerMin}.dylib
|
||||
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.$${aVerMaj}.$${aVerMin}.$${aVerMic}.dylib
|
||||
} else {
|
||||
# override qmake soname versionong logic
|
||||
QMAKE_LFLAGS_SONAME =
|
||||
QMAKE_LFLAGS += -Wl,-soname=lib$${TARGET}.so.$${aVerMaj}.$${aVerMin}
|
||||
|
||||
# extend clean with versioned .so files
|
||||
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.so
|
||||
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.so.$${aVerMaj}
|
||||
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.so.$${aVerMaj}.$${aVerMin}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -26,9 +26,7 @@
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Graphic3d_Texture1D.hxx>
|
||||
#include <Graphic3d_Texture1Dsegment.hxx>
|
||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||
#include <Graphic3d_Texture2D.hxx>
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
@@ -81,7 +79,7 @@ void Sample2D_Image::SetContext (const Handle(AIS_InteractiveContext)& theContex
|
||||
this->Set(TopoDS_Shape(myFace));
|
||||
|
||||
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
||||
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(myFilename);
|
||||
Handle(Graphic3d_Texture2D) aTexture = new Graphic3d_Texture2D (myFilename);
|
||||
aTexture->DisableModulate();
|
||||
myDrawer->ShadingAspect()->Aspect()->SetTextureMap (aTexture);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetTextureMapOn();
|
||||
|
@@ -34,6 +34,8 @@ enum AIS_MouseGesture
|
||||
AIS_MouseGesture_Pan, //!< view panning gesture
|
||||
AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture
|
||||
AIS_MouseGesture_RotateView, //!< view rotation gesture
|
||||
AIS_MouseGesture_Drag, //!< object dragging;
|
||||
//! press button to start, move mouse to define rectangle, release to finish
|
||||
};
|
||||
|
||||
//! Map defining mouse gestures.
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_StructureManager.hxx>
|
||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||
#include <Graphic3d_Texture2D.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
@@ -278,17 +278,17 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
|
||||
TCollection_AsciiString aTextureDesc;
|
||||
if (!myTexturePixMap.IsNull())
|
||||
{
|
||||
myTexture = new Graphic3d_Texture2Dmanual (myTexturePixMap);
|
||||
myTexture = new Graphic3d_Texture2D (myTexturePixMap);
|
||||
aTextureDesc = " (custom image)";
|
||||
}
|
||||
else if (myPredefTexture != Graphic3d_NOT_2D_UNKNOWN)
|
||||
{
|
||||
myTexture = new Graphic3d_Texture2Dmanual (myPredefTexture);
|
||||
myTexture = new Graphic3d_Texture2D (myPredefTexture);
|
||||
aTextureDesc = TCollection_AsciiString(" (predefined texture ") + myTexture->GetId() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
myTexture = new Graphic3d_Texture2Dmanual (myTextureFile.ToCString());
|
||||
myTexture = new Graphic3d_Texture2D (myTextureFile.ToCString());
|
||||
aTextureDesc = TCollection_AsciiString(" (") + myTextureFile + ")";
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include <PrsMgr_PresentationManager.hxx>
|
||||
|
||||
class Graphic3d_AspectFillArea3d;
|
||||
class Graphic3d_Texture2Dmanual;
|
||||
class Graphic3d_Texture2D;
|
||||
|
||||
//! This class allows to map textures on shapes.
|
||||
//! Presentations modes AIS_WireFrame (0) and AIS_Shaded (1) behave in the same manner as in AIS_Shape,
|
||||
@@ -184,7 +184,7 @@ protected: //! @name overridden methods
|
||||
|
||||
protected: //! @name presentation fields
|
||||
|
||||
Handle(Graphic3d_Texture2Dmanual) myTexture;
|
||||
Handle(Graphic3d_Texture2D) myTexture;
|
||||
Handle(Graphic3d_AspectFillArea3d) myAspect;
|
||||
|
||||
protected: //! @name texture source fields
|
||||
|
@@ -92,6 +92,7 @@ AIS_ViewController::AIS_ViewController()
|
||||
myTouchPanThresholdPx (4.0f),
|
||||
myTouchZoomThresholdPx (6.0f),
|
||||
myTouchZoomRatio (0.13f),
|
||||
myTouchDraggingThresholdPx (6.0f),
|
||||
//
|
||||
myNbTouchesLast (0),
|
||||
myUpdateStartPointPan (true),
|
||||
@@ -133,6 +134,8 @@ AIS_ViewController::AIS_ViewController()
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_MiddleButton, AIS_MouseGesture_Pan);
|
||||
myMouseGestureMap.Bind (Aspect_VKeyMouse_MiddleButton | Aspect_VKeyFlags_CTRL, AIS_MouseGesture_Pan);
|
||||
|
||||
myMouseGestureMapDrag.Bind (Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_Drag);
|
||||
|
||||
myXRTeleportHaptic.Duration = 3600.0f;
|
||||
myXRTeleportHaptic.Frequency = 0.1f;
|
||||
myXRTeleportHaptic.Amplitude = 0.2f;
|
||||
@@ -261,12 +264,21 @@ void AIS_ViewController::flushBuffers (const Handle(AIS_InteractiveContext)& ,
|
||||
myUI.Dragging.ToStop = false;
|
||||
myGL.Dragging.ToStop = true;
|
||||
}
|
||||
else if (myUI.Dragging.ToStart)
|
||||
else
|
||||
{
|
||||
myUI.Dragging.ToStart = false;
|
||||
myGL.Dragging.ToStart = true;
|
||||
myGL.Dragging.PointStart = myUI.Dragging.PointStart;
|
||||
if (myUI.Dragging.ToStart)
|
||||
{
|
||||
myUI.Dragging.ToStart = false;
|
||||
myGL.Dragging.ToStart = true;
|
||||
myGL.Dragging.PointStart = myUI.Dragging.PointStart;
|
||||
}
|
||||
if (myUI.Dragging.ToMove)
|
||||
{
|
||||
myUI.Dragging.ToMove = false;
|
||||
myGL.Dragging.ToMove = true;
|
||||
}
|
||||
}
|
||||
|
||||
myGL.Dragging.PointTo = myUI.Dragging.PointTo;
|
||||
|
||||
if (myUI.OrbitRotation.ToStart)
|
||||
@@ -351,6 +363,7 @@ void AIS_ViewController::flushGestures (const Handle(AIS_InteractiveContext)& ,
|
||||
const Graphic3d_Vec2d aRotDelta = aTouch.To - myGL.OrbitRotation.PointStart;
|
||||
myGL.OrbitRotation.ToRotate = true;
|
||||
myGL.OrbitRotation.PointTo = myGL.OrbitRotation.PointStart + aRotDelta * aRotAccel;
|
||||
myGL.Dragging.ToMove = true;
|
||||
myGL.Dragging.PointTo.SetValues ((int )aTouch.To.x(), (int )aTouch.To.y());
|
||||
}
|
||||
else
|
||||
@@ -358,6 +371,7 @@ void AIS_ViewController::flushGestures (const Handle(AIS_InteractiveContext)& ,
|
||||
const Graphic3d_Vec2d aRotDelta = aTouch.To - myGL.ViewRotation.PointStart;
|
||||
myGL.ViewRotation.ToRotate = true;
|
||||
myGL.ViewRotation.PointTo = myGL.ViewRotation.PointStart + aRotDelta * aRotAccel;
|
||||
myGL.Dragging.ToMove = true;
|
||||
myGL.Dragging.PointTo.SetValues ((int )aTouch.To.x(), (int )aTouch.To.y());
|
||||
}
|
||||
|
||||
@@ -780,6 +794,19 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
|
||||
UpdatePolySelection (thePoint, true);
|
||||
break;
|
||||
}
|
||||
case AIS_MouseGesture_Drag:
|
||||
{
|
||||
if (myToAllowDragging)
|
||||
{
|
||||
myUI.Dragging.ToStart = true;
|
||||
myUI.Dragging.PointStart = thePoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
myMouseActiveGesture = AIS_MouseGesture_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AIS_MouseGesture_NONE:
|
||||
{
|
||||
break;
|
||||
@@ -787,12 +814,19 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
|
||||
}
|
||||
}
|
||||
|
||||
if (theButtons == Aspect_VKeyMouse_LeftButton
|
||||
&& theModifiers == Aspect_VKeyFlags_NONE
|
||||
&& myToAllowDragging)
|
||||
AIS_MouseGesture aSecGesture = AIS_MouseGesture_NONE;
|
||||
if (myMouseGestureMapDrag.Find (theButtons | theModifiers, aSecGesture))
|
||||
{
|
||||
myUI.Dragging.ToStart = true;
|
||||
myUI.Dragging.PointStart = thePoint;
|
||||
if (aSecGesture == AIS_MouseGesture_Drag
|
||||
&& myToAllowDragging)
|
||||
{
|
||||
myUI.Dragging.ToStart = true;
|
||||
myUI.Dragging.PointStart = thePoint;
|
||||
if (myMouseActiveGesture == AIS_MouseGesture_NONE)
|
||||
{
|
||||
myMouseActiveGesture = aSecGesture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -932,6 +966,8 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
|
||||
myUI.ViewRotation.PointTo = Graphic3d_Vec2d (myMousePressPoint.x(), myMousePressPoint.y())
|
||||
+ Graphic3d_Vec2d (aRotDelta.x(), aRotDelta.y()) * aRotAccel;
|
||||
}
|
||||
|
||||
myUI.Dragging.ToMove = true;
|
||||
myUI.Dragging.PointTo = thePoint;
|
||||
|
||||
myMouseProgressPoint = thePoint;
|
||||
@@ -991,6 +1027,31 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AIS_MouseGesture_Drag:
|
||||
{
|
||||
if (!myToAllowDragging)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
const double aDragTol = theIsEmulated
|
||||
? double(myTouchToleranceScale) * myTouchDraggingThresholdPx
|
||||
: 0.0;
|
||||
if (double (Abs (aDelta.x()) + Abs (aDelta.y())) > aDragTol)
|
||||
{
|
||||
const double aRotAccel = myNavigationMode == AIS_NavigationMode_FirstPersonWalk ? myMouseAccel : myOrbitAccel;
|
||||
const Graphic3d_Vec2i aRotDelta = thePoint - myMousePressPoint;
|
||||
myUI.ViewRotation.ToRotate = true;
|
||||
myUI.ViewRotation.PointTo = Graphic3d_Vec2d (myMousePressPoint.x(), myMousePressPoint.y())
|
||||
+ Graphic3d_Vec2d (aRotDelta.x(), aRotDelta.y()) * aRotAccel;
|
||||
myUI.Dragging.ToMove = true;
|
||||
myUI.Dragging.PointTo = thePoint;
|
||||
|
||||
myMouseProgressPoint = thePoint;
|
||||
toUpdateView = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
@@ -2913,8 +2974,7 @@ void AIS_ViewController::handleDynamicHighlight (const Handle(AIS_InteractiveCon
|
||||
myGL.OrbitRotation.ToRotate = false;
|
||||
myGL.ViewRotation .ToRotate = false;
|
||||
}
|
||||
else if (myGL.OrbitRotation.ToRotate
|
||||
|| myGL.ViewRotation.ToRotate)
|
||||
else if (myGL.Dragging.ToMove)
|
||||
{
|
||||
OnObjectDragged (theCtx, theView, AIS_DragAction_Update);
|
||||
myGL.OrbitRotation.ToRotate = false;
|
||||
|
@@ -757,6 +757,7 @@ protected: //! @name mouse input variables
|
||||
Standard_ShortReal myScrollZoomRatio; //!< distance ratio for mapping mouse scroll event to zoom; 15.0 by default
|
||||
|
||||
AIS_MouseGestureMap myMouseGestureMap; //!< map defining mouse gestures
|
||||
AIS_MouseGestureMap myMouseGestureMapDrag; //!< secondary map defining mouse gestures for dragging
|
||||
AIS_MouseGesture myMouseActiveGesture; //!< initiated mouse gesture (by pressing mouse button)
|
||||
AIS_MouseSelectionSchemeMap
|
||||
myMouseSelectionSchemes; //!< map defining selection schemes bound to mouse + modifiers
|
||||
@@ -777,6 +778,7 @@ protected: //! @name multi-touch input variables
|
||||
Standard_ShortReal myTouchPanThresholdPx; //!< threshold for starting two-touch panning gesture in pixels; 4 by default
|
||||
Standard_ShortReal myTouchZoomThresholdPx; //!< threshold for starting two-touch zoom (pitch) gesture in pixels; 6 by default
|
||||
Standard_ShortReal myTouchZoomRatio; //!< distance ratio for mapping two-touch zoom (pitch) gesture from pixels to zoom; 0.13 by default
|
||||
Standard_ShortReal myTouchDraggingThresholdPx; //!< distance for starting one-touch dragging gesture in pixels; 6 by default
|
||||
|
||||
Aspect_Touch myTouchClick; //!< single touch position for handling clicks
|
||||
OSD_Timer myTouchDoubleTapTimer; //!< timer for handling double tap
|
||||
|
@@ -87,12 +87,13 @@ public:
|
||||
struct _draggingParams
|
||||
{
|
||||
bool ToStart; //!< start dragging
|
||||
bool ToMove; //!< perform dragging
|
||||
bool ToStop; //!< stop dragging
|
||||
bool ToAbort; //!< abort dragging (restore previous position)
|
||||
Graphic3d_Vec2i PointStart; //!< drag start point
|
||||
Graphic3d_Vec2i PointTo; //!< drag end point
|
||||
|
||||
_draggingParams() : ToStart (false), ToStop (false), ToAbort (false) {}
|
||||
_draggingParams() : ToStart (false), ToMove (false), ToStop (false), ToAbort (false) {}
|
||||
} Dragging;
|
||||
|
||||
struct _orbitRotation
|
||||
@@ -141,6 +142,7 @@ public:
|
||||
Panning.ToStart = false;
|
||||
Panning.ToPan = false;
|
||||
Dragging.ToStart = false;
|
||||
Dragging.ToMove = false;
|
||||
Dragging.ToStop = false;
|
||||
Dragging.ToAbort = false;
|
||||
OrbitRotation.ToStart = false;
|
||||
|
@@ -23,14 +23,14 @@
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
|
||||
//! Texture holder.
|
||||
class AIS_XRTrackedDevice::XRTexture : public Graphic3d_Texture2Dmanual
|
||||
class AIS_XRTrackedDevice::XRTexture : public Graphic3d_Texture2D
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
XRTexture (const Handle(Image_Texture)& theImageSource,
|
||||
const Graphic3d_TextureUnit theUnit = Graphic3d_TextureUnit_BaseColor)
|
||||
: Graphic3d_Texture2Dmanual (""), myImageSource (theImageSource)
|
||||
: Graphic3d_Texture2D (""), myImageSource (theImageSource)
|
||||
{
|
||||
if (!theImageSource->TextureId().IsEmpty())
|
||||
{
|
||||
|
@@ -114,19 +114,20 @@ public:
|
||||
Standard_EXPORT virtual Standard_Boolean IsVPeriodic() const;
|
||||
|
||||
Standard_EXPORT virtual Standard_Real VPeriod() const;
|
||||
|
||||
|
||||
//! Computes the point of parameters U,V on the surface.
|
||||
//! Tip: use GeomLib::NormEstim() to calculate surface normal at specified (U, V) point.
|
||||
Standard_EXPORT virtual gp_Pnt Value (const Standard_Real U, const Standard_Real V) const;
|
||||
|
||||
|
||||
//! Computes the point of parameters U,V on the surface.
|
||||
Standard_EXPORT virtual void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const;
|
||||
|
||||
//! Computes the point and the first derivatives on
|
||||
//! the surface.
|
||||
//! Raised if the continuity of the current
|
||||
//! intervals is not C1.
|
||||
//! Computes the point and the first derivatives on the surface.
|
||||
//! Raised if the continuity of the current intervals is not C1.
|
||||
//!
|
||||
//! Tip: use GeomLib::NormEstim() to calculate surface normal at specified (U, V) point.
|
||||
Standard_EXPORT virtual void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const;
|
||||
|
||||
|
||||
//! Computes the point, the first and second
|
||||
//! derivatives on the surface.
|
||||
//! Raised if the continuity of the current
|
||||
|
@@ -30,34 +30,6 @@ IMPLEMENT_STANDARD_RTTIEXT(Adaptor3d_TopolTool,Standard_Transient)
|
||||
|
||||
#define myInfinite Precision::Infinite()
|
||||
|
||||
static void GetConeApexParam(const gp_Cone& C, Standard_Real& U, Standard_Real& V)
|
||||
{
|
||||
const gp_Ax3& Pos = C.Position();
|
||||
Standard_Real Radius = C.RefRadius();
|
||||
Standard_Real SAngle = C.SemiAngle();
|
||||
const gp_Pnt& P = C.Apex();
|
||||
|
||||
gp_Trsf T;
|
||||
T.SetTransformation (Pos);
|
||||
gp_Pnt Ploc = P.Transformed (T);
|
||||
|
||||
if(Ploc.X() ==0.0 && Ploc.Y()==0.0 ) {
|
||||
U = 0.0;
|
||||
}
|
||||
else if ( -Radius > Ploc.Z()* Tan(SAngle) ) {
|
||||
// the point is at the `wrong` side of the apex
|
||||
U = atan2(-Ploc.Y(), -Ploc.X());
|
||||
}
|
||||
else {
|
||||
U = atan2(Ploc.Y(),Ploc.X());
|
||||
}
|
||||
if (U < -1.e-16) U += (M_PI+M_PI);
|
||||
else if (U < 0) U = 0;
|
||||
|
||||
V = sin(SAngle) * ( Ploc.X() * cos(U) + Ploc.Y() * sin(U) - Radius)
|
||||
+ cos(SAngle) * Ploc.Z();
|
||||
}
|
||||
|
||||
|
||||
Adaptor3d_TopolTool::Adaptor3d_TopolTool ()
|
||||
: myNbSamplesU(-1),
|
||||
@@ -1376,3 +1348,39 @@ Standard_Boolean Adaptor3d_TopolTool::IsUniformSampling() const
|
||||
return Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConeApexParam
|
||||
//purpose : Computes the cone's apex parameters
|
||||
//=======================================================================
|
||||
void Adaptor3d_TopolTool::GetConeApexParam (const gp_Cone& theC, Standard_Real& theU, Standard_Real& theV)
|
||||
{
|
||||
const gp_Ax3& Pos = theC.Position();
|
||||
Standard_Real Radius = theC.RefRadius();
|
||||
Standard_Real SAngle = theC.SemiAngle();
|
||||
const gp_Pnt& P = theC.Apex();
|
||||
|
||||
gp_Trsf T;
|
||||
T.SetTransformation(Pos);
|
||||
gp_Pnt Ploc = P.Transformed(T);
|
||||
|
||||
if (Ploc.X() == 0.0 && Ploc.Y() == 0.0)
|
||||
{
|
||||
theU = 0.0;
|
||||
}
|
||||
else if (-Radius > Ploc.Z() * Tan(SAngle))
|
||||
{
|
||||
// the point is at the `wrong` side of the apex
|
||||
theU = atan2(-Ploc.Y(), -Ploc.X());
|
||||
}
|
||||
else
|
||||
{
|
||||
theU = atan2(Ploc.Y(), Ploc.X());
|
||||
}
|
||||
|
||||
if (theU < -1.e-16) theU += (M_PI + M_PI);
|
||||
else if (theU < 0) theU = 0;
|
||||
|
||||
theV = sin(SAngle) * (Ploc.X() * cos(theU) + Ploc.Y() * sin(theU) - Radius)
|
||||
+ cos(SAngle) * Ploc.Z();
|
||||
}
|
||||
|
@@ -146,6 +146,12 @@ public:
|
||||
//! Returns true if provide uniform sampling of points.
|
||||
Standard_EXPORT virtual Standard_Boolean IsUniformSampling() const;
|
||||
|
||||
//! Computes the cone's apex parameters.
|
||||
//! @param[in] theC conical surface
|
||||
//! @param[in] theU U parameter of cone's apex
|
||||
//! @param[in] theV V parameter of cone's apex
|
||||
Standard_EXPORT static void GetConeApexParam (const gp_Cone& theC, Standard_Real& theU, Standard_Real& theV);
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Adaptor3d_TopolTool,Standard_Transient)
|
||||
|
||||
protected:
|
||||
|
@@ -141,17 +141,18 @@ public:
|
||||
virtual Standard_Real VPeriod() const Standard_OVERRIDE { return mySurf.VPeriod(); }
|
||||
|
||||
//! Computes the point of parameters U,V on the surface.
|
||||
//! Tip: use GeomLib::NormEstim() to calculate surface normal at specified (U, V) point.
|
||||
Standard_EXPORT gp_Pnt Value (const Standard_Real U, const Standard_Real V) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Computes the point of parameters U,V on the surface.
|
||||
Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const Standard_OVERRIDE;
|
||||
|
||||
//! Computes the point and the first derivatives on
|
||||
//! the surface.
|
||||
//! Raised if the continuity of the current
|
||||
//! intervals is not C1.
|
||||
|
||||
//! Computes the point and the first derivatives on the surface.
|
||||
//! Raised if the continuity of the current intervals is not C1.
|
||||
//!
|
||||
//! Tip: use GeomLib::NormEstim() to calculate surface normal at specified (U, V) point.
|
||||
Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Computes the point, the first and second
|
||||
//! derivatives on the surface.
|
||||
//! Raised if the continuity of the current
|
||||
|
@@ -861,7 +861,8 @@ static Standard_Boolean Filling(const TopoDS_Shape& EF,
|
||||
Prof2 = BRep_Tool::Curve(E2, f2, l2);
|
||||
|
||||
// Indeed, both Prof1 and Prof2 are the same curves but in different positions
|
||||
|
||||
// Prof1's param domain may equals to Prof2's param domain *(-1), which means EF.Orientation() == EL.Orientation()
|
||||
Standard_Boolean bSameCurveDomain = EF.Orientation() != EL.Orientation();
|
||||
gp_Pnt P1, P2, P;
|
||||
|
||||
// Choose the angle of opening
|
||||
@@ -887,7 +888,8 @@ static Standard_Boolean Filling(const TopoDS_Shape& EF,
|
||||
}
|
||||
}
|
||||
|
||||
const gp_Pnt aP2 = Prof2->Value(aPrm[aMaxIdx]).Transformed(aTf);
|
||||
const Standard_Real aPrm2[] = { f2, 0.5*(f2 + l2), l2 };
|
||||
const gp_Pnt aP2 = Prof2->Value(aPrm2[bSameCurveDomain ? aMaxIdx : 2 - aMaxIdx]).Transformed(aTf);
|
||||
const gp_Vec2d aV1(aP1[aMaxIdx].Z(), aP1[aMaxIdx].X());
|
||||
const gp_Vec2d aV2(aP2.Z(), aP2.X());
|
||||
if (aV1.SquareMagnitude() <= gp::Resolution() ||
|
||||
|
@@ -695,7 +695,7 @@ Standard_Boolean BRepTools::Write (const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
|
||||
std::shared_ptr<std::ostream> aStream = aFileSystem->OpenOStream (theFile, std::ios::out);
|
||||
std::shared_ptr<std::ostream> aStream = aFileSystem->OpenOStream (theFile, std::ios::out | std::ios::binary);
|
||||
if (aStream.get() == NULL || !aStream->good())
|
||||
{
|
||||
return Standard_False;
|
||||
|
@@ -78,19 +78,11 @@ Standard_Boolean CDF_Store::SetFolder(const Standard_ExtString aFolder) {
|
||||
Standard_Boolean CDF_Store::SetFolder(const TCollection_ExtendedString& aFolder) {
|
||||
|
||||
TCollection_ExtendedString theFolder(aFolder);
|
||||
Standard_Integer l = theFolder.Length();
|
||||
Standard_Integer aLen = theFolder.Length();
|
||||
|
||||
// if the last character is the folder separator (which is always the first character)
|
||||
// it is removed.
|
||||
// This is correct for Unix systems but not for Windows! VMS and MAC? Thomas Haller, 23.11.01
|
||||
if(l > 1) {
|
||||
#ifndef _WIN32
|
||||
if(theFolder.Value(l) == theFolder.Value(1)) theFolder.Trunc(l-1);
|
||||
#else
|
||||
if (theFolder.Value(l) == '/' || theFolder.Value(l) == '\\')
|
||||
theFolder.Trunc(l-1);
|
||||
#endif
|
||||
}
|
||||
// if the last character is the folder separator, remove it.
|
||||
if (aLen > 1 && (theFolder.Value(aLen) == '/' || theFolder.Value(aLen) == '\\'))
|
||||
theFolder.Trunc(aLen-1);
|
||||
|
||||
if(theMetaDataDriver->FindFolder(theFolder)) {
|
||||
myCurrentDocument->SetRequestedFolder(theFolder);
|
||||
|
@@ -195,7 +195,7 @@ Standard_Boolean D3DHost_FrameBuffer::InitD3dInterop (const Handle(OpenGl_Contex
|
||||
|
||||
const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, myDepthFormat);
|
||||
if (aDepthFormat.IsValid()
|
||||
&& !myDepthStencilTexture->Init (theCtx, aDepthFormat, Graphic3d_Vec2i (aSizeX, aSizeY), Graphic3d_TOT_2D))
|
||||
&& !myDepthStencilTexture->Init (theCtx, aDepthFormat, Graphic3d_Vec2i (aSizeX, aSizeY), Graphic3d_TypeOfTexture_2D))
|
||||
{
|
||||
Release (theCtx.get());
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
|
@@ -75,146 +75,150 @@ static OSD_Timer aTimer;
|
||||
|
||||
extern Standard_Boolean Draw_Chrono;
|
||||
|
||||
static Standard_Integer chronom(Draw_Interpretor& di,
|
||||
Standard_Integer n,const char** a)
|
||||
static Standard_Integer dchronom (Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
if ((n == 1) || (*a[1] == '0') || (*a[1] == '1')) {
|
||||
if (n == 1)
|
||||
if (theNbArgs == 1
|
||||
|| (theNbArgs == 2
|
||||
&& (*theArgVec[1] == '0'
|
||||
|| *theArgVec[1] == '1')))
|
||||
{
|
||||
if (theNbArgs == 1)
|
||||
{
|
||||
Draw_Chrono = !Draw_Chrono;
|
||||
}
|
||||
else
|
||||
Draw_Chrono = (*a[1] == '1');
|
||||
{
|
||||
Draw_Chrono = (*theArgVec[1] == '1');
|
||||
}
|
||||
|
||||
if (Draw_Chrono) di << "Chronometers activated.\n";
|
||||
else di << "Chronometers deactivated.\n";
|
||||
theDI << (Draw_Chrono
|
||||
? "Chronometers activated.\n"
|
||||
: "Chronometers deactivated.\n");
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
|
||||
Handle(Draw_Chronometer) C;
|
||||
if (!D.IsNull()) {
|
||||
C = Handle(Draw_Chronometer)::DownCast(D);
|
||||
}
|
||||
if (C.IsNull()) {
|
||||
C = new Draw_Chronometer();
|
||||
Draw::Set(a[1],C,Standard_False);
|
||||
}
|
||||
if (n <= 2) {
|
||||
C->Timer().Reset();
|
||||
}
|
||||
else {
|
||||
for (Standard_Integer anIter = 2; anIter < n; ++anIter)
|
||||
{
|
||||
TCollection_AsciiString anArg (a[anIter]);
|
||||
anArg.LowerCase();
|
||||
|
||||
if (anArg == "reset")
|
||||
{
|
||||
C->Timer().Reset();
|
||||
}
|
||||
else if (anArg == "restart")
|
||||
{
|
||||
C->Timer().Restart();
|
||||
}
|
||||
else if (anArg == "start")
|
||||
{
|
||||
C->Timer().Start();
|
||||
}
|
||||
else if (anArg == "stop")
|
||||
{
|
||||
C->Timer().Stop();
|
||||
}
|
||||
else if (anArg == "show")
|
||||
{
|
||||
C->Timer().Show();
|
||||
}
|
||||
else if (anArg == "counter")
|
||||
{
|
||||
Standard_Real aSeconds,aCPUtime;
|
||||
Standard_Integer aMinutes, aHours;
|
||||
C->Timer().Show(aSeconds,aMinutes,aHours,aCPUtime);
|
||||
std::cout << "COUNTER " << a[++anIter] << ": " << aCPUtime << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Unknown argument '" << a[anIter] << "'!\n";
|
||||
}
|
||||
const char* aTimerName = theArgVec[1];
|
||||
Handle(Draw_Chronometer) aChronom;
|
||||
if (Handle(Draw_Drawable3D) aDrawable = Draw::Get (aTimerName))
|
||||
{
|
||||
aChronom = Handle(Draw_Chronometer)::DownCast (aDrawable);
|
||||
}
|
||||
if (aChronom.IsNull())
|
||||
{
|
||||
aChronom = new Draw_Chronometer();
|
||||
Draw::Set (aTimerName, aChronom, false);
|
||||
}
|
||||
|
||||
if (theNbArgs <= 2)
|
||||
{
|
||||
aChronom->Timer().Reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
const bool toShowCout = (TCollection_AsciiString (theArgVec[0]) == "chrono");
|
||||
int aNbPuts = false;
|
||||
for (Standard_Integer anIter = 2; anIter < theNbArgs; ++anIter)
|
||||
{
|
||||
TCollection_AsciiString anArg (theArgVec[anIter]);
|
||||
anArg.LowerCase();
|
||||
if (anArg == "-reset"
|
||||
|| anArg == "reset")
|
||||
{
|
||||
aChronom->Timer().Reset();
|
||||
}
|
||||
else if (anArg == "-restart"
|
||||
|| anArg == "restart")
|
||||
{
|
||||
aChronom->Timer().Restart();
|
||||
}
|
||||
else if (anArg == "-start"
|
||||
|| anArg == "-resume"
|
||||
|| anArg == "start")
|
||||
{
|
||||
aChronom->Timer().Start();
|
||||
}
|
||||
else if (anArg == "-stop"
|
||||
|| anArg == "-pause"
|
||||
|| anArg == "stop")
|
||||
{
|
||||
aChronom->Timer().Stop();
|
||||
}
|
||||
else if (anArg == "-show"
|
||||
|| anArg == "show")
|
||||
{
|
||||
if (toShowCout)
|
||||
{
|
||||
aChronom->Timer().Show (std::cout);
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_SStream aStream;
|
||||
aChronom->Timer().Show (aStream);
|
||||
theDI << aStream;
|
||||
}
|
||||
}
|
||||
else if (anIter + 1 < theNbArgs
|
||||
&& (anArg == "-counter"
|
||||
|| anArg == "counter"))
|
||||
{
|
||||
Standard_Real aSeconds = 0.0, aCPUtime = 0.0;
|
||||
Standard_Integer aMinutes = 0, aHours = 0;
|
||||
aChronom->Timer().Show (aSeconds, aMinutes, aHours, aCPUtime);
|
||||
if (toShowCout)
|
||||
{
|
||||
std::cout << "COUNTER " << theArgVec[++anIter] << ": " << aCPUtime << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << "COUNTER " << theArgVec[++anIter] << ": " << aCPUtime << "\n";
|
||||
}
|
||||
}
|
||||
else if (anArg == "-elapsed")
|
||||
{
|
||||
if (++aNbPuts > 1) { theDI << " "; }
|
||||
theDI << aChronom->Timer().ElapsedTime();
|
||||
}
|
||||
else if (anArg == "-cpu"
|
||||
|| anArg == "-usercpu"
|
||||
|| anArg == "-cpuuser")
|
||||
{
|
||||
if (++aNbPuts > 1) { theDI << " "; }
|
||||
theDI << aChronom->Timer().UserTimeCPU();
|
||||
}
|
||||
else if (anArg == "-systemcpu"
|
||||
|| anArg == "-syscpu"
|
||||
|| anArg == "-cpusystem"
|
||||
|| anArg == "-cpusys")
|
||||
{
|
||||
if (++aNbPuts > 1) { theDI << " "; }
|
||||
theDI << aChronom->Timer().SystemTimeCPU();
|
||||
}
|
||||
else if (anArg == "-thread"
|
||||
|| anArg == "-threadonly")
|
||||
{
|
||||
bool isThreadOnly = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anIter);
|
||||
aChronom->Timer().Stop();
|
||||
aChronom->Timer().Reset();
|
||||
aChronom->Timer().SetThisThreadOnly (isThreadOnly);
|
||||
}
|
||||
else if (anArg == "-process")
|
||||
{
|
||||
bool isProcessTime = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anIter);
|
||||
aChronom->Timer().Stop();
|
||||
aChronom->Timer().Reset();
|
||||
aChronom->Timer().SetThisThreadOnly (!isProcessTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << "Syntax error at '" << theArgVec[anIter] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer dchronom(Draw_Interpretor& theDI,
|
||||
Standard_Integer n,const char** a)
|
||||
{
|
||||
if ((n == 1) || (*a[1] == '0') || (*a[1] == '1')) {
|
||||
if (n == 1)
|
||||
Draw_Chrono = !Draw_Chrono;
|
||||
else
|
||||
Draw_Chrono = (*a[1] == '1');
|
||||
|
||||
if (Draw_Chrono) theDI << "Chronometers activated.\n";
|
||||
else theDI << "Chronometers deactivated.\n";
|
||||
}
|
||||
else {
|
||||
Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
|
||||
Handle(Draw_Chronometer) C;
|
||||
if (!D.IsNull()) {
|
||||
C = Handle(Draw_Chronometer)::DownCast(D);
|
||||
}
|
||||
if (C.IsNull()) {
|
||||
C = new Draw_Chronometer();
|
||||
Draw::Set(a[1],C,Standard_False);
|
||||
}
|
||||
if (n <= 2) {
|
||||
C->Timer().Reset();
|
||||
}
|
||||
else {
|
||||
for (Standard_Integer anIter = 2; anIter < n; ++anIter)
|
||||
{
|
||||
TCollection_AsciiString anArg (a[anIter]);
|
||||
anArg.LowerCase();
|
||||
|
||||
if (anArg == "reset")
|
||||
{
|
||||
C->Timer().Reset();
|
||||
}
|
||||
else if (anArg == "restart")
|
||||
{
|
||||
C->Timer().Restart();
|
||||
}
|
||||
else if (anArg == "start")
|
||||
{
|
||||
C->Timer().Start();
|
||||
}
|
||||
else if (anArg == "stop")
|
||||
{
|
||||
C->Timer().Stop();
|
||||
}
|
||||
else if (anArg == "show")
|
||||
{
|
||||
Standard_SStream ss;
|
||||
C->Timer().Show(ss);
|
||||
theDI << ss;
|
||||
}
|
||||
else if (anArg == "counter")
|
||||
{
|
||||
Standard_Real aSeconds,aCPUtime;
|
||||
Standard_Integer aMinutes, aHours;
|
||||
C->Timer().Show(aSeconds,aMinutes,aHours,aCPUtime);
|
||||
theDI << "COUNTER " << a[++anIter] << ": " << aCPUtime << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << "Unknown argument '" << a[anIter] << "'!\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ifbatch
|
||||
//purpose :
|
||||
@@ -878,7 +882,8 @@ static int dmeminfo (Draw_Interpretor& theDI,
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Unknown argument '" << theArgVec[anIter] << "'!\n";
|
||||
theDI << "Syntax error at '" << theArgVec[anIter] << "'!\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1304,11 +1309,33 @@ void Draw::BasicCommands(Draw_Interpretor& theCommands)
|
||||
__FILE__,Draw_wait,g);
|
||||
theCommands.Add("cpulimit","cpulimit [nbseconds], no args remove limits",
|
||||
__FILE__,cpulimit,g);
|
||||
theCommands.Add("chrono","chrono [name action [action...]] \n Operates named timer.\n"
|
||||
" Supported actions: reset, start, stop, restart, show, counter [text].\n"
|
||||
" Without arguments enables / disables global timer for all DRAW commands.",
|
||||
__FILE__,chronom,g);
|
||||
theCommands.Add("dchrono","see help of chrono command",
|
||||
|
||||
const char* aChronoHelp =
|
||||
"chrono Name [-start] [-stop] [-reset] [-restart] [-counter Text]"
|
||||
"\n\t\t: [-show] [-elapsed] [-userCPU] [-sysCPU]"
|
||||
"\n\t\t: [-thread|-process {0|1}]"
|
||||
"\n\t\t: Operates named timer:"
|
||||
"\n\t\t: -start starts (resumes) timer"
|
||||
"\n\t\t: -stop stops (pauses) timer"
|
||||
"\n\t\t: -reset resets timer progress"
|
||||
"\n\t\t: -restart resets and starts timer"
|
||||
"\n\t\t: -show prints timer progress"
|
||||
"\n\t\t: ('dchrono' puts into Tcl, 'chrono' puts into std::cout)"
|
||||
"\n\t\t: -elapsed prints elapsed time in seconds"
|
||||
"\n\t\t: -userCPU prints user CPU time in seconds"
|
||||
"\n\t\t: -sysCPU prints system CPU time in seconds"
|
||||
"\n\t\t: -counter prints 'COUNTER <Text>'"
|
||||
"\n\t\t: -thread stops timer and sets measuring of CPU time for this thread only (FALSE by default)"
|
||||
"\n\t\t: -process stops timer and sets measuring of CPU time for all threads (TRUE by default)"
|
||||
"\n\t\t: Without arguments enables / disables global timer for all DRAW commands."
|
||||
"\n\t\t: chrono {0|1}"
|
||||
"\n\t\t: Typical usage:"
|
||||
"\n\t\t: chrono t -restart"
|
||||
"\n\t\t: <algorithm>"
|
||||
"\n\t\t: chrono t -stop -show";
|
||||
theCommands.Add("chrono", aChronoHelp,
|
||||
__FILE__,dchronom,g);
|
||||
theCommands.Add("dchrono", aChronoHelp,
|
||||
__FILE__,dchronom,g);
|
||||
theCommands.Add("mallochook",
|
||||
"debug memory allocation/deallocation, w/o args for help",
|
||||
|
@@ -14,69 +14,50 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <Draw_Chronometer.hxx>
|
||||
#include <Draw_Display.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <OSD_Timer.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Draw_Chronometer,Draw_Drawable3D)
|
||||
#include <Draw_Display.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Draw_Chronometer, Draw_Drawable3D)
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_Chronometer
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Draw_Chronometer::Draw_Chronometer()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Timer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
OSD_Timer& Draw_Chronometer::Timer()
|
||||
{
|
||||
return myTimer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Chronometer::DrawOn(Draw_Display&)const
|
||||
void Draw_Chronometer::DrawOn (Draw_Display& ) const
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) Draw_Chronometer::Copy()const
|
||||
Handle(Draw_Drawable3D) Draw_Chronometer::Copy() const
|
||||
{
|
||||
Handle(Draw_Chronometer) C = new Draw_Chronometer();
|
||||
return C;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Draw_Chronometer::Dump(Standard_OStream& S)const
|
||||
void Draw_Chronometer::Dump (Standard_OStream& S) const
|
||||
{
|
||||
S << "Chronometer : ";
|
||||
S << "Chronometer, ";
|
||||
myTimer.Show (S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
|
@@ -17,32 +17,25 @@
|
||||
#ifndef _Draw_Chronometer_HeaderFile
|
||||
#define _Draw_Chronometer_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
|
||||
#include <OSD_Timer.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
class Draw_Display;
|
||||
#include <OSD_Timer.hxx>
|
||||
|
||||
|
||||
class Draw_Chronometer;
|
||||
DEFINE_STANDARD_HANDLE(Draw_Chronometer, Draw_Drawable3D)
|
||||
|
||||
//! Class to store chronometer variables.
|
||||
class Draw_Chronometer : public Draw_Drawable3D
|
||||
{
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Draw_Chronometer, Draw_Drawable3D)
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT Draw_Chronometer();
|
||||
|
||||
Standard_EXPORT OSD_Timer& Timer();
|
||||
|
||||
//! Does nothhing,
|
||||
|
||||
//! Return timer.
|
||||
OSD_Timer& Timer() { return myTimer; }
|
||||
|
||||
//! Does nothing,
|
||||
Standard_EXPORT void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! For variable copy.
|
||||
Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const Standard_OVERRIDE;
|
||||
|
||||
@@ -52,28 +45,10 @@ public:
|
||||
//! For variable whatis command.
|
||||
Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Draw_Chronometer,Draw_Drawable3D)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
OSD_Timer myTimer;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _Draw_Chronometer_HeaderFile
|
||||
|
@@ -92,7 +92,7 @@ static Standard_Integer save (Draw_Interpretor& theDI,
|
||||
|
||||
const char* aName = theArgVec[2];
|
||||
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
|
||||
std::shared_ptr<std::ostream> aStream = aFileSystem->OpenOStream (aName, std::ios::out);
|
||||
std::shared_ptr<std::ostream> aStream = aFileSystem->OpenOStream (aName, std::ios::out | std::ios::binary);
|
||||
aStream->precision (15);
|
||||
if (aStream.get() == NULL || !aStream->good())
|
||||
{
|
||||
|
@@ -1402,10 +1402,10 @@ proc _run_test {scriptsdir group gridname casefile echo} {
|
||||
append stats "MEMORY DELTA: [expr ($memuse - $membase) / 1024] KiB\n"
|
||||
}
|
||||
uplevel dchrono _timer stop
|
||||
set time [uplevel dchrono _timer show]
|
||||
if { [regexp -nocase {CPU user time:[ \t]*([0-9.e-]+)} $time res cpu_usr] } {
|
||||
append stats "TOTAL CPU TIME: $cpu_usr sec\n"
|
||||
}
|
||||
set cpu_usr [uplevel dchrono _timer -userCPU]
|
||||
set elps [uplevel dchrono _timer -elapsed]
|
||||
append stats "TOTAL CPU TIME: $cpu_usr sec\n"
|
||||
append stats "ELAPSED TIME: $elps sec\n"
|
||||
if { $dlog_exists && ! $echo } {
|
||||
dlog add $stats
|
||||
} else {
|
||||
|
@@ -176,6 +176,8 @@ gp_Vec ElSLib::ConeDN (const Standard_Real U,
|
||||
}
|
||||
else if(Nv == 1) {
|
||||
Xdir.Multiply(sin(SAngle));
|
||||
if (Nu == 0)
|
||||
Xdir.Add(Pos.Direction().XYZ() * cos(SAngle));
|
||||
return gp_Vec(Xdir);
|
||||
}
|
||||
return gp_Vec(0.0,0.0,0.0);
|
||||
|
@@ -602,6 +602,9 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
|
||||
const Bnd_Range aRange(theUt21, theUt22);
|
||||
Bnd_Range aProjRng1;
|
||||
|
||||
// Precision of the calculation depends on circles radii
|
||||
const Standard_Real aPrecision = Max(Epsilon(myC[0]->Circle().Radius()), Epsilon(myC[1]->Circle().Radius()));
|
||||
|
||||
// Project arc of the 1st circle between points theUt11 and theUt12 to the
|
||||
// 2nd circle. It is necessary to chose correct arc from two possible ones.
|
||||
|
||||
@@ -663,7 +666,7 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
|
||||
// myIsParallel = TRUE and only the least distance will be returned.
|
||||
//4. Arcs are not parallel. Then several (or single) extremas will be returned.
|
||||
|
||||
if (aRng.Delta() > Precision::Angular())
|
||||
if (aRng.Delta() > Precision::Confusion())
|
||||
{
|
||||
Standard_Real aPar = 0.0;
|
||||
aRng.GetIntermediatePoint(0.5, aPar);
|
||||
@@ -678,7 +681,7 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
|
||||
aMinSqD = Min(aMinSqD, ExtPCir.SquareDistance(anExtID));
|
||||
}
|
||||
|
||||
if (aMinSqD <= aMinSquareDist + 10.* Epsilon(1. + aMinSqD))
|
||||
if (aMinSqD <= aMinSquareDist + (1. + aMinSqD) * aPrecision)
|
||||
{
|
||||
ClearSolutions();
|
||||
mySqDist.Append(aMinSqD);
|
||||
@@ -703,7 +706,6 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Nearer solution can be found
|
||||
}
|
||||
else if (!aRng.IsVoid())
|
||||
@@ -779,7 +781,7 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
|
||||
imin = k;
|
||||
}
|
||||
}
|
||||
if (aDmin <= aMinSquareDist + 10.* Epsilon(1. + aDmin))
|
||||
if (aDmin <= aMinSquareDist + (1. + aDmin) * aPrecision)
|
||||
{
|
||||
if (imin == 0)
|
||||
{
|
||||
|
@@ -120,6 +120,15 @@ Extrema_GenExtCS::Extrema_GenExtCS()
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ~Extrema_GenExtCS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Extrema_GenExtCS::~Extrema_GenExtCS()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Extrema_GenExtCS
|
||||
//purpose :
|
||||
|
@@ -35,9 +35,12 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Empty constructor.
|
||||
Standard_EXPORT Extrema_GenExtCS();
|
||||
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT ~Extrema_GenExtCS();
|
||||
|
||||
//! It calculates all the distances.
|
||||
//! The function F(u,v)=distance(S1(u1,v1),S2(u2,v2)) has an
|
||||
//! extremum when gradient(F)=0. The algorithm searches
|
||||
|
@@ -224,7 +224,19 @@ Extrema_GenExtPS::Extrema_GenExtPS()
|
||||
myAlgo = Extrema_ExtAlgo_Grad;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ~Extrema_GenExtPS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Extrema_GenExtPS::~Extrema_GenExtPS()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Extrema_GenExtPS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Extrema_GenExtPS::Extrema_GenExtPS (const gp_Pnt& P,
|
||||
const Adaptor3d_Surface& S,
|
||||
const Standard_Integer NbU,
|
||||
|
@@ -37,8 +37,12 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Empty constructor.
|
||||
Standard_EXPORT Extrema_GenExtPS();
|
||||
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT ~Extrema_GenExtPS();
|
||||
|
||||
//! It calculates all the distances.
|
||||
//! The function F(u,v)=distance(P,S(u,v)) has an
|
||||
//! extremum when gradient(F)=0. The algorithm searches
|
||||
|
@@ -118,6 +118,15 @@ Extrema_GenExtSS::Extrema_GenExtSS()
|
||||
myInit = Standard_False;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ~Extrema_GenExtSS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Extrema_GenExtSS::~Extrema_GenExtSS()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Extrema_GenExtSS
|
||||
//purpose :
|
||||
|
@@ -36,9 +36,12 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Empty constructor.
|
||||
Standard_EXPORT Extrema_GenExtSS();
|
||||
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT ~Extrema_GenExtSS();
|
||||
|
||||
//! It calculates all the distances.
|
||||
//! The function F(u,v)=distance(S1(u1,v1),S2(u2,v2)) has an
|
||||
//! extremum when gradient(F)=0. The algorithm searches
|
||||
|
@@ -27,29 +27,24 @@ class gp_Vec;
|
||||
class Geom_Surface;
|
||||
DEFINE_STANDARD_HANDLE(Geom_Surface, Geom_Geometry)
|
||||
|
||||
//! Describes the common behavior of surfaces in 3D
|
||||
//! space. The Geom package provides many
|
||||
//! implementations of concrete derived surfaces, such as
|
||||
//! planes, cylinders, cones, spheres and tori, surfaces of
|
||||
//! linear extrusion, surfaces of revolution, Bezier and
|
||||
//! BSpline surfaces, and so on.
|
||||
//! The key characteristic of these surfaces is that they
|
||||
//! are parameterized. Geom_Surface demonstrates:
|
||||
//! - how to work with the parametric equation of a
|
||||
//! surface to compute the point of parameters (u,
|
||||
//! v), and, at this point, the 1st, 2nd ... Nth derivative,
|
||||
//! Describes the common behavior of surfaces in 3D space.
|
||||
//! The Geom package provides many implementations of concrete derived surfaces,
|
||||
//! such as planes, cylinders, cones, spheres and tori, surfaces of linear extrusion,
|
||||
//! surfaces of revolution, Bezier and BSpline surfaces, and so on.
|
||||
//! The key characteristic of these surfaces is that they are parameterized.
|
||||
//! Geom_Surface demonstrates:
|
||||
//! - how to work with the parametric equation of a surface
|
||||
//! to compute the point of parameters (u, v), and, at this point, the 1st, 2nd ... Nth derivative;
|
||||
//! - how to find global information about a surface in
|
||||
//! each parametric direction (for example, level of
|
||||
//! continuity, whether the surface is closed, its
|
||||
//! periodicity, the bounds of the parameters and so on), and
|
||||
//! - how the parameters change when geometric
|
||||
//! transformations are applied to the surface, or the
|
||||
//! orientation is modified.
|
||||
//! Note that all surfaces must have a geometric
|
||||
//! continuity, and any surface is at least "C0". Generally,
|
||||
//! continuity is checked at construction time or when the
|
||||
//! curve is edited. Where this is not the case, the
|
||||
//! documentation makes this explicit.
|
||||
//! each parametric direction (for example, level of continuity, whether the surface is closed,
|
||||
//! its periodicity, the bounds of the parameters and so on);
|
||||
//! - how the parameters change when geometric transformations are applied to the surface,
|
||||
//! or the orientation is modified.
|
||||
//!
|
||||
//! Note that all surfaces must have a geometric continuity, and any surface is at least "C0".
|
||||
//! Generally, continuity is checked at construction time or when the curve is edited.
|
||||
//! Where this is not the case, the documentation makes this explicit.
|
||||
//!
|
||||
//! Warning
|
||||
//! The Geom package does not prevent the construction of
|
||||
//! surfaces with null areas, or surfaces which self-intersect.
|
||||
@@ -142,47 +137,42 @@ public:
|
||||
//! equal to Precision::Infinite: instead of Standard_Real::LastReal.
|
||||
Standard_EXPORT virtual void Bounds (Standard_Real& U1, Standard_Real& U2, Standard_Real& V1, Standard_Real& V2) const = 0;
|
||||
|
||||
//! Checks whether this surface is closed in the u
|
||||
//! parametric direction.
|
||||
//! Returns true if, in the u parametric direction: taking
|
||||
//! uFirst and uLast as the parametric bounds in
|
||||
//! the u parametric direction, for each parameter v, the
|
||||
//! distance between the points P(uFirst, v) and
|
||||
//! Checks whether this surface is closed in the u parametric direction.
|
||||
//! Returns true if, in the u parametric direction:
|
||||
//! taking uFirst and uLast as the parametric bounds in
|
||||
//! the u parametric direction, for each parameter v,
|
||||
//! the distance between the points P(uFirst, v) and
|
||||
//! P(uLast, v) is less than or equal to gp::Resolution().
|
||||
Standard_EXPORT virtual Standard_Boolean IsUClosed() const = 0;
|
||||
|
||||
//! Checks whether this surface is closed in the u
|
||||
//! parametric direction.
|
||||
//! Returns true if, in the v parametric
|
||||
//! direction: taking vFirst and vLast as the
|
||||
//! parametric bounds in the v parametric direction, for
|
||||
//! each parameter u, the distance between the points
|
||||
//! P(u, vFirst) and P(u, vLast) is less than
|
||||
//! or equal to gp::Resolution().
|
||||
//! Checks whether this surface is closed in the u parametric direction.
|
||||
//! Returns true if, in the v parametric direction:
|
||||
//! taking vFirst and vLast as the parametric bounds in the v parametric direction,
|
||||
//! for each parameter u, the distance between the points
|
||||
//! P(u, vFirst) and P(u, vLast) is less than or equal to gp::Resolution().
|
||||
Standard_EXPORT virtual Standard_Boolean IsVClosed() const = 0;
|
||||
|
||||
//! Checks if this surface is periodic in the u
|
||||
//! parametric direction. Returns true if:
|
||||
//! Checks if this surface is periodic in the u parametric direction.
|
||||
//! Returns true if:
|
||||
//! - this surface is closed in the u parametric direction, and
|
||||
//! - there is a constant T such that the distance
|
||||
//! between the points P (u, v) and P (u + T,
|
||||
//! v) (or the points P (u, v) and P (u, v +
|
||||
//! T)) is less than or equal to gp::Resolution().
|
||||
//! between the points P (u, v) and P (u + T, v)
|
||||
//! (or the points P (u, v) and P (u, v + T)) is less than or equal to gp::Resolution().
|
||||
//!
|
||||
//! Note: T is the parametric period in the u parametric direction.
|
||||
Standard_EXPORT virtual Standard_Boolean IsUPeriodic() const = 0;
|
||||
|
||||
//! Returns the period of this surface in the u
|
||||
//! parametric direction.
|
||||
//! raises if the surface is not uperiodic.
|
||||
//! Returns the period of this surface in the u parametric direction.
|
||||
//! Raises if the surface is not uperiodic.
|
||||
Standard_EXPORT virtual Standard_Real UPeriod() const;
|
||||
|
||||
//! Checks if this surface is periodic in the v
|
||||
//! parametric direction. Returns true if:
|
||||
//! Checks if this surface is periodic in the v parametric direction.
|
||||
//! Returns true if:
|
||||
//! - this surface is closed in the v parametric direction, and
|
||||
//! - there is a constant T such that the distance
|
||||
//! between the points P (u, v) and P (u + T,
|
||||
//! v) (or the points P (u, v) and P (u, v +
|
||||
//! T)) is less than or equal to gp::Resolution().
|
||||
//! between the points P (u, v) and P (u + T, v)
|
||||
//! (or the points P (u, v) and P (u, v + T)) is less than or equal to gp::Resolution().
|
||||
//!
|
||||
//! Note: T is the parametric period in the v parametric direction.
|
||||
Standard_EXPORT virtual Standard_Boolean IsVPeriodic() const = 0;
|
||||
|
||||
@@ -197,25 +187,24 @@ public:
|
||||
Standard_EXPORT virtual Handle(Geom_Curve) VIso (const Standard_Real V) const = 0;
|
||||
|
||||
//! Returns the Global Continuity of the surface in direction U and V :
|
||||
//! C0 : only geometric continuity,
|
||||
//! C1 : continuity of the first derivative all along the surface,
|
||||
//! C2 : continuity of the second derivative all along the surface,
|
||||
//! C3 : continuity of the third derivative all along the surface,
|
||||
//! G1 : tangency continuity all along the surface,
|
||||
//! G2 : curvature continuity all along the surface,
|
||||
//! CN : the order of continuity is infinite.
|
||||
//! Example :
|
||||
//! - C0: only geometric continuity,
|
||||
//! - C1: continuity of the first derivative all along the surface,
|
||||
//! - C2: continuity of the second derivative all along the surface,
|
||||
//! - C3: continuity of the third derivative all along the surface,
|
||||
//! - G1: tangency continuity all along the surface,
|
||||
//! - G2: curvature continuity all along the surface,
|
||||
//! - CN: the order of continuity is infinite.
|
||||
//!
|
||||
//! Example:
|
||||
//! If the surface is C1 in the V parametric direction and C2
|
||||
//! in the U parametric direction Shape = C1.
|
||||
Standard_EXPORT virtual GeomAbs_Shape Continuity() const = 0;
|
||||
|
||||
//! Returns the order of continuity of the surface in the
|
||||
//! U parametric direction.
|
||||
//! Returns the order of continuity of the surface in the U parametric direction.
|
||||
//! Raised if N < 0.
|
||||
Standard_EXPORT virtual Standard_Boolean IsCNu (const Standard_Integer N) const = 0;
|
||||
|
||||
//! Returns the order of continuity of the surface in the
|
||||
//! V parametric direction.
|
||||
//! Returns the order of continuity of the surface in the V parametric direction.
|
||||
//! Raised if N < 0.
|
||||
Standard_EXPORT virtual Standard_Boolean IsCNv (const Standard_Integer N) const = 0;
|
||||
|
||||
@@ -226,9 +215,10 @@ public:
|
||||
Standard_EXPORT virtual void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const = 0;
|
||||
|
||||
|
||||
//! Computes the point P and the first derivatives in the
|
||||
//! directions U and V at this point.
|
||||
//! Computes the point P and the first derivatives in the directions U and V at this point.
|
||||
//! Raised if the continuity of the surface is not C1.
|
||||
//!
|
||||
//! Tip: use GeomLib::NormEstim() to calculate surface normal at specified (U, V) point.
|
||||
Standard_EXPORT virtual void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const = 0;
|
||||
|
||||
//! Computes the point P, the first and the second derivatives in
|
||||
@@ -241,21 +231,18 @@ public:
|
||||
//! Raised if the continuity of the surface is not C2.
|
||||
Standard_EXPORT virtual void D3 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const = 0;
|
||||
|
||||
//! ---Purpose ;
|
||||
//! Computes the derivative of order Nu in the direction U and Nv
|
||||
//! in the direction V at the point P(U, V).
|
||||
//! Computes the derivative of order Nu in the direction U and Nv in the direction V at the point P(U, V).
|
||||
//!
|
||||
//! Raised if the continuity of the surface is not CNu in the U
|
||||
//! direction or not CNv in the V direction.
|
||||
//! Raised if the continuity of the surface is not CNu in the U direction or not CNv in the V direction.
|
||||
//! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
|
||||
Standard_EXPORT virtual gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const = 0;
|
||||
|
||||
//! Computes the point of parameter U on the surface.
|
||||
//! Computes the point of parameter (U, V) on the surface.
|
||||
//!
|
||||
//! It is implemented with D0
|
||||
//! It is implemented with D0.
|
||||
//! Tip: use GeomLib::NormEstim() to calculate surface normal at specified (U, V) point.
|
||||
//!
|
||||
//! Raised only for an "OffsetSurface" if it is not possible to
|
||||
//! compute the current point.
|
||||
//! Raised only for an "OffsetSurface" if it is not possible to compute the current point.
|
||||
Standard_EXPORT gp_Pnt Value (const Standard_Real U, const Standard_Real V) const;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
|
@@ -58,6 +58,65 @@ static const Standard_Real PosTol = Precision::PConfusion() / 2;
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Geom2dAdaptor_Curve, Adaptor2d_Curve2d)
|
||||
|
||||
static void DefinFPeriod(const Standard_Real theLower,
|
||||
const Standard_Real theUpper,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Real thePeriod,
|
||||
Standard_Real &theCurFirst,
|
||||
Standard_Integer &theFPer);
|
||||
|
||||
static void DefinLPeriod(const Standard_Real theLower,
|
||||
const Standard_Real theUpper,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Real thePeriod,
|
||||
Standard_Real &theCurLast,
|
||||
Standard_Integer &theLPer);
|
||||
|
||||
static Standard_Integer LocalNbIntervals(const TColStd_Array1OfReal& theTK,
|
||||
const TColStd_Array1OfInteger& theTM,
|
||||
const TColStd_Array1OfInteger& theInter,
|
||||
const Standard_Integer theCurDegree,
|
||||
const Standard_Integer theNb,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Boolean thePeriodicCur,
|
||||
Standard_Integer theNbIntervals,
|
||||
Standard_Real theLower = 0,
|
||||
Standard_Real thePeriod = 0,
|
||||
Standard_Integer theIndex1 = 0,
|
||||
Standard_Integer theIndex2 = 0);
|
||||
|
||||
static void WriteIntervals(const TColStd_Array1OfReal &theTK,
|
||||
const TColStd_Array1OfInteger &theInter,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Integer theIndex1,
|
||||
const Standard_Integer theIndex2,
|
||||
const Standard_Real theCurPeriod,
|
||||
const Standard_Boolean theFlagForFirst,
|
||||
TColStd_Array1OfReal &theT,
|
||||
TColStd_Array1OfInteger &theFinalIntervals,
|
||||
Standard_Integer &theNbIntervals,
|
||||
Standard_Integer &theCurInt);
|
||||
|
||||
static void SpreadInt(const TColStd_Array1OfReal &theTK,
|
||||
const TColStd_Array1OfInteger &theTM,
|
||||
const TColStd_Array1OfInteger &theInter,
|
||||
const Standard_Integer theCurDegree,
|
||||
const Standard_Integer theNb,
|
||||
const Standard_Integer theFPer,
|
||||
const Standard_Integer theLPer,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Real theLower,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real thePeriod,
|
||||
const Standard_Real theLastParam,
|
||||
const Standard_Real theEps,
|
||||
TColStd_Array1OfReal &theT,
|
||||
Standard_Integer &theNbIntervals);
|
||||
|
||||
//=======================================================================
|
||||
//function : ShallowCopy
|
||||
//purpose :
|
||||
@@ -115,7 +174,7 @@ GeomAbs_Shape Geom2dAdaptor_Curve::LocalContinuity(const Standard_Real U1,
|
||||
if ( myBSplineCurve->IsPeriodic() && Index1 == Nb )
|
||||
Index1 = 1;
|
||||
|
||||
if ( Index2 - Index1 <= 0) {
|
||||
if ((Index2 - Index1 <= 0) && (!myBSplineCurve->IsPeriodic())) {
|
||||
MultMax = 100; // CN entre 2 Noeuds consecutifs
|
||||
}
|
||||
else {
|
||||
@@ -295,6 +354,158 @@ GeomAbs_Shape Geom2dAdaptor_Curve::Continuity() const
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DefinFPeriod
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DefinFPeriod(const Standard_Real theLower,
|
||||
const Standard_Real theUpper,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Real thePeriod,
|
||||
Standard_Real &theCurFirst,
|
||||
Standard_Integer &theFPer)
|
||||
{
|
||||
if (theCurFirst >= theLower)
|
||||
{
|
||||
while (theCurFirst >= theUpper)
|
||||
{
|
||||
theCurFirst = theCurFirst - thePeriod;
|
||||
theFPer++;
|
||||
}
|
||||
if (Abs(theUpper - theCurFirst) <= theEps)
|
||||
{
|
||||
theFPer++;
|
||||
theCurFirst = theLower;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (theCurFirst < theLower)
|
||||
{
|
||||
theCurFirst = theCurFirst + thePeriod;
|
||||
if (Abs(theLower - theCurFirst) > theEps)
|
||||
{
|
||||
theFPer--;
|
||||
}
|
||||
}
|
||||
|
||||
if (Abs(theUpper - theCurFirst) <= theEps)
|
||||
{
|
||||
theCurFirst = theLower;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DefinLPeriod
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DefinLPeriod(const Standard_Real theLower,
|
||||
const Standard_Real theUpper,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Real thePeriod,
|
||||
Standard_Real &theCurLast,
|
||||
Standard_Integer &theLPer)
|
||||
{
|
||||
if (theCurLast >= theLower)
|
||||
{
|
||||
if ((theCurLast >= theUpper) && (Abs(theCurLast - theUpper) <= theEps))
|
||||
{
|
||||
theCurLast = theUpper;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (theCurLast >= theUpper)
|
||||
{
|
||||
theCurLast = theCurLast - thePeriod;
|
||||
theLPer++;
|
||||
}
|
||||
if (Abs(theUpper - theCurLast) <= theEps)
|
||||
{
|
||||
theCurLast = theLower;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (theCurLast < theLower)
|
||||
{
|
||||
theCurLast = theCurLast + thePeriod;
|
||||
if (Abs(theLower - theCurLast) > theEps)
|
||||
{
|
||||
theLPer--;
|
||||
}
|
||||
}
|
||||
if (Abs(theUpper - theCurLast) <= theEps)
|
||||
{
|
||||
theCurLast = theLower;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LocalNbIntervals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer LocalNbIntervals(const TColStd_Array1OfReal& theTK,
|
||||
const TColStd_Array1OfInteger& theTM,
|
||||
const TColStd_Array1OfInteger& theInter,
|
||||
const Standard_Integer theCurDegree,
|
||||
const Standard_Integer theNb,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Boolean thePeriodicCur,
|
||||
Standard_Integer theNbIntervals,
|
||||
Standard_Real theLower,
|
||||
Standard_Real thePeriod,
|
||||
Standard_Integer theIndex1,
|
||||
Standard_Integer theIndex2)
|
||||
{
|
||||
Standard_Real aNewFirst = theFirst;
|
||||
Standard_Real aNewLast = theLast;
|
||||
if (theIndex1 == 0)
|
||||
{
|
||||
BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theFirst,
|
||||
thePeriodicCur, 1, theNb, theIndex1, aNewFirst);
|
||||
}
|
||||
if (theIndex2 == 0)
|
||||
{
|
||||
BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theLast,
|
||||
thePeriodicCur, 1, theNb, theIndex2, aNewLast);
|
||||
}
|
||||
// Protection against theFirst = UFirst - eps, which located as ULast - eps
|
||||
if (thePeriodicCur && ((aNewLast - aNewFirst) < Precision::PConfusion()))
|
||||
{
|
||||
if (Abs(aNewLast - theLower) < Precision::PConfusion())
|
||||
{
|
||||
aNewLast += thePeriod;
|
||||
}
|
||||
else
|
||||
{
|
||||
aNewFirst -= thePeriod;
|
||||
}
|
||||
}
|
||||
|
||||
if (Abs(aNewFirst - theTK(theIndex1 + 1)) < theEps)
|
||||
{
|
||||
theIndex1++;
|
||||
}
|
||||
if ((aNewLast - theTK(theIndex2)) > theEps)
|
||||
{
|
||||
theIndex2++;
|
||||
}
|
||||
for (Standard_Integer i = 1; i <= theNbInt; i++)
|
||||
{
|
||||
if (theInter(i) > theIndex1 && theInter(i) < theIndex2) theNbIntervals++;
|
||||
}
|
||||
return theNbIntervals;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbIntervals
|
||||
//purpose :
|
||||
@@ -306,77 +517,179 @@ Standard_Integer Geom2dAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const
|
||||
Standard_Integer NbSplit;
|
||||
if (myTypeCurve == GeomAbs_BSplineCurve) {
|
||||
Standard_Integer FirstIndex = myBSplineCurve->FirstUKnotIndex();
|
||||
Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex();
|
||||
TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1);
|
||||
if ( S > Continuity()) {
|
||||
Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex();
|
||||
TColStd_Array1OfInteger Inter(1, LastIndex - FirstIndex + 1);
|
||||
Standard_Boolean aContPer = (S >= Continuity()) && myBSplineCurve->IsPeriodic();
|
||||
Standard_Boolean aContNotPer = (S > Continuity()) && !myBSplineCurve->IsPeriodic();
|
||||
if (aContPer || aContNotPer) {
|
||||
Standard_Integer Cont;
|
||||
switch ( S) {
|
||||
switch (S) {
|
||||
case GeomAbs_G1:
|
||||
case GeomAbs_G2:
|
||||
throw Standard_DomainError("Geom2dAdaptor_Curve::NbIntervals");
|
||||
break;
|
||||
throw Standard_DomainError("Geom2dAdaptor_Curve::NbIntervals");
|
||||
break;
|
||||
case GeomAbs_C0:
|
||||
myNbIntervals = 1;
|
||||
break;
|
||||
myNbIntervals = 1;
|
||||
break;
|
||||
case GeomAbs_C1:
|
||||
case GeomAbs_C2:
|
||||
case GeomAbs_C3:
|
||||
case GeomAbs_CN:
|
||||
{
|
||||
if ( S == GeomAbs_C1) Cont = 1;
|
||||
else if ( S == GeomAbs_C2) Cont = 2;
|
||||
else if ( S == GeomAbs_C3) Cont = 3;
|
||||
else Cont = myBSplineCurve->Degree();
|
||||
Standard_Integer Degree = myBSplineCurve->Degree();
|
||||
Standard_Integer NbKnots = myBSplineCurve->NbKnots();
|
||||
TColStd_Array1OfInteger Mults (1, NbKnots);
|
||||
myBSplineCurve->Multiplicities (Mults);
|
||||
NbSplit = 1;
|
||||
Standard_Integer Index = FirstIndex;
|
||||
Inter (NbSplit) = Index;
|
||||
case GeomAbs_C3:
|
||||
case GeomAbs_CN:
|
||||
{
|
||||
if (S == GeomAbs_C1) Cont = 1;
|
||||
else if (S == GeomAbs_C2) Cont = 2;
|
||||
else if (S == GeomAbs_C3) Cont = 3;
|
||||
else Cont = myBSplineCurve->Degree();
|
||||
Standard_Integer Degree = myBSplineCurve->Degree();
|
||||
Standard_Integer NbKnots = myBSplineCurve->NbKnots();
|
||||
TColStd_Array1OfInteger Mults(1, NbKnots);
|
||||
myBSplineCurve->Multiplicities(Mults);
|
||||
NbSplit = 1;
|
||||
Standard_Integer Index = FirstIndex;
|
||||
Inter(NbSplit) = Index;
|
||||
Index++;
|
||||
NbSplit++;
|
||||
while (Index < LastIndex)
|
||||
{
|
||||
if (Degree - Mults(Index) < Cont)
|
||||
{
|
||||
Inter(NbSplit) = Index;
|
||||
NbSplit++;
|
||||
}
|
||||
Index++;
|
||||
NbSplit++;
|
||||
while (Index < LastIndex)
|
||||
{
|
||||
if (Degree - Mults (Index) < Cont)
|
||||
{
|
||||
Inter (NbSplit) = Index;
|
||||
NbSplit++;
|
||||
}
|
||||
Index++;
|
||||
}
|
||||
Inter (NbSplit) = Index;
|
||||
|
||||
Standard_Integer NbInt = NbSplit-1;
|
||||
|
||||
Standard_Integer Nb = myBSplineCurve->NbKnots();
|
||||
Standard_Integer Index1 = 0;
|
||||
Standard_Integer Index2 = 0;
|
||||
Standard_Real newFirst, newLast;
|
||||
TColStd_Array1OfReal TK(1,Nb);
|
||||
TColStd_Array1OfInteger TM(1,Nb);
|
||||
myBSplineCurve->Knots(TK);
|
||||
myBSplineCurve->Multiplicities(TM);
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,myFirst,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1,Nb,Index1,newFirst);
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,myLast,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1,Nb,Index2,newLast);
|
||||
|
||||
// On decale eventuellement les indices
|
||||
// On utilise une "petite" tolerance, la resolution ne doit
|
||||
// servir que pour les tres longue courbes....(PRO9248)
|
||||
Standard_Real Eps = Min(Resolution(Precision::Confusion()),
|
||||
Precision::PConfusion());
|
||||
if ( Abs(newFirst-TK(Index1+1))< Eps) Index1++;
|
||||
if ( newLast-TK(Index2)> Eps) Index2++;
|
||||
|
||||
myNbIntervals = 1;
|
||||
for ( Standard_Integer i=1; i<=NbInt; i++)
|
||||
if (Inter(i)>Index1 && Inter(i)<Index2) myNbIntervals++;
|
||||
}
|
||||
break;
|
||||
Inter(NbSplit) = Index;
|
||||
|
||||
Standard_Integer NbInt = NbSplit - 1;
|
||||
|
||||
Standard_Integer Nb = myBSplineCurve->NbKnots();
|
||||
TColStd_Array1OfReal TK(1, Nb);
|
||||
TColStd_Array1OfInteger TM(1, Nb);
|
||||
myBSplineCurve->Knots(TK);
|
||||
myBSplineCurve->Multiplicities(TM);
|
||||
Standard_Real Eps = Min(Resolution(Precision::Confusion()),
|
||||
Precision::PConfusion());
|
||||
|
||||
myNbIntervals = 1;
|
||||
|
||||
if (!myBSplineCurve->IsPeriodic())
|
||||
{
|
||||
myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
myFirst, myLast, Eps, Standard_False, myNbIntervals);
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Real aCurFirst = myFirst;
|
||||
Standard_Real aCurLast = myLast;
|
||||
|
||||
Standard_Real aLower = myBSplineCurve->FirstParameter();
|
||||
Standard_Real anUpper = myBSplineCurve->LastParameter();
|
||||
|
||||
if ((Abs(aCurFirst - aLower) < Eps) && (aCurFirst < aLower))
|
||||
{
|
||||
aCurFirst = aLower;
|
||||
}
|
||||
if ((Abs(aCurLast - anUpper) < Eps) && (aCurLast < anUpper))
|
||||
{
|
||||
aCurLast = anUpper;
|
||||
}
|
||||
|
||||
Standard_Real aPeriod = myBSplineCurve->Period();
|
||||
Standard_Integer aLPer = 1; Standard_Integer aFPer = 1;
|
||||
|
||||
if ((Abs(aLower - myFirst) < Eps) && (aCurFirst < aLower))
|
||||
{
|
||||
aCurFirst = aLower;
|
||||
}
|
||||
else
|
||||
{
|
||||
DefinFPeriod(aLower, anUpper,
|
||||
Eps, aPeriod, aCurFirst, aFPer);
|
||||
}
|
||||
DefinLPeriod(aLower, anUpper,
|
||||
Eps, aPeriod, aCurLast, aLPer);
|
||||
|
||||
if ((Abs(aLower - myFirst) < Eps) && (Abs(anUpper - myLast) < Eps))
|
||||
{
|
||||
myNbIntervals = NbInt;
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Integer aSumPer = Abs(aLPer - aFPer);
|
||||
|
||||
Standard_Real aFirst = 0;
|
||||
if (aLower < 0 && anUpper == 0)
|
||||
{
|
||||
if (Abs(aCurLast) < Eps)
|
||||
{
|
||||
aCurLast = 0;
|
||||
}
|
||||
aFirst = aLower;
|
||||
}
|
||||
|
||||
if (aSumPer <= 1)
|
||||
{
|
||||
if ((Abs(myFirst - TK(Nb) - aPeriod * (aFPer - 1)) <= Eps) && (myLast < (TK(Nb) + aPeriod * (aLPer - 1))))
|
||||
{
|
||||
myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
myFirst, myLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod);
|
||||
return myNbIntervals;
|
||||
}
|
||||
if ((Abs(myFirst - aLower) < Eps) && (Abs(myLast - anUpper) < Eps))
|
||||
{
|
||||
myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
myFirst, myLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod);
|
||||
return myNbIntervals;
|
||||
}
|
||||
}
|
||||
|
||||
if (aSumPer != 0)
|
||||
{
|
||||
Standard_Integer aFInt = 0;
|
||||
Standard_Integer aLInt = 0;
|
||||
Standard_Integer aPInt = NbInt;
|
||||
|
||||
if ((aCurFirst != aPeriod) || ((aCurFirst != anUpper) && (Abs(myFirst) < Eps)))
|
||||
{
|
||||
aFInt = 1;
|
||||
}
|
||||
if ((aCurLast != 0) && (aCurLast != anUpper))
|
||||
{
|
||||
aLInt = 1;
|
||||
}
|
||||
|
||||
aFInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
aCurFirst, anUpper, Eps, Standard_True, aFInt, aLower, aPeriod);
|
||||
|
||||
if (aCurLast == anUpper)
|
||||
{
|
||||
aLInt = NbInt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Abs(aCurLast - aFirst) > Eps)
|
||||
{
|
||||
aLInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
aFirst, aCurLast, Eps, Standard_True, aLInt, aLower, aPeriod, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
aLInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
aFirst, aCurLast, Eps, Standard_True, aLInt, aLower, aPeriod);
|
||||
}
|
||||
}
|
||||
|
||||
myNbIntervals = aFInt + aLInt + aPInt * (aSumPer - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
aCurFirst, aCurLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -399,6 +712,204 @@ Standard_Integer Geom2dAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const
|
||||
return myNbIntervals;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WriteIntervals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void WriteIntervals(const TColStd_Array1OfReal &theTK,
|
||||
const TColStd_Array1OfInteger &theInter,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Integer theIndex1,
|
||||
const Standard_Integer theIndex2,
|
||||
const Standard_Real theCurPeriod,
|
||||
const Standard_Boolean theFlagForFirst,
|
||||
TColStd_Array1OfReal &theT,
|
||||
TColStd_Array1OfInteger &theFinalIntervals,
|
||||
Standard_Integer &theNbIntervals,
|
||||
Standard_Integer &theCurInt)
|
||||
{
|
||||
if (theFlagForFirst)
|
||||
{
|
||||
for (Standard_Integer anId = 1; anId <= theNbInt; anId++)
|
||||
{
|
||||
if (theInter(anId) > theIndex1 && theInter(anId) <= theIndex2)
|
||||
{
|
||||
theNbIntervals++;
|
||||
theFinalIntervals(theNbIntervals) = theInter(anId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer anId = 1; anId <= theNbInt; anId++)
|
||||
{
|
||||
if (theInter(anId) > theIndex1 && theInter(anId) < theIndex2)
|
||||
{
|
||||
theNbIntervals++;
|
||||
theFinalIntervals(theNbIntervals) = theInter(anId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
theFinalIntervals(theNbIntervals + 1) = theIndex2;
|
||||
|
||||
for (Standard_Integer anId = theCurInt; anId <= theNbIntervals + 1; anId++)
|
||||
{
|
||||
theT(anId) = theTK(theFinalIntervals(anId)) + theCurPeriod;
|
||||
theCurInt++;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SpreadInt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SpreadInt(const TColStd_Array1OfReal &theTK,
|
||||
const TColStd_Array1OfInteger &theTM,
|
||||
const TColStd_Array1OfInteger &theInter,
|
||||
const Standard_Integer theCurDegree,
|
||||
const Standard_Integer theNb,
|
||||
const Standard_Integer theFPer,
|
||||
const Standard_Integer theLPer,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Real theLower,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real thePeriod,
|
||||
const Standard_Real theLastParam,
|
||||
const Standard_Real theEps,
|
||||
TColStd_Array1OfReal &theT,
|
||||
Standard_Integer &theNbIntervals)
|
||||
{
|
||||
Standard_Integer anIndex1 = 0;
|
||||
Standard_Integer anIndex2 = 0;
|
||||
Standard_Real aNewFirst, aNewLast;
|
||||
Standard_Integer anUpper;
|
||||
BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theFirst,
|
||||
Standard_True, 1, theNb, anIndex1, aNewFirst);
|
||||
BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theLastParam,
|
||||
Standard_True, 1, theNb, anIndex2, aNewLast);
|
||||
|
||||
if (Abs(aNewFirst - theTK(anIndex1 + 1)) < theEps)
|
||||
{
|
||||
anIndex1++;
|
||||
}
|
||||
if ((aNewLast - theTK(anIndex2)) > theEps)
|
||||
{
|
||||
anIndex2++;
|
||||
}
|
||||
theNbIntervals = 1;
|
||||
|
||||
if (anIndex1 == theNb)
|
||||
{
|
||||
anIndex1 = 1;
|
||||
}
|
||||
|
||||
// Count the max number of boundaries of intervals
|
||||
if (Abs(theLPer - theFPer) > 1)
|
||||
{
|
||||
anUpper = theNb - anIndex1 + anIndex2 + (theLPer - theFPer - 1) * theNb + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
anUpper = theNb - anIndex1 + anIndex2 + 1;
|
||||
}
|
||||
|
||||
if (theLPer == theFPer)
|
||||
{
|
||||
anUpper = theInter.Upper();
|
||||
}
|
||||
TColStd_Array1OfInteger aFinalIntervals(1, anUpper);
|
||||
aFinalIntervals(1) = anIndex1;
|
||||
|
||||
// If first and last are in the same period
|
||||
if ((Abs(theLPer - theFPer) == 0))
|
||||
{
|
||||
Standard_Integer aCurInt = 1;
|
||||
Standard_Real aCurPeriod = theFPer * thePeriod;
|
||||
|
||||
if (theFirst == aNewFirst && theLast == aNewLast)
|
||||
{
|
||||
aCurPeriod = 0;
|
||||
}
|
||||
WriteIntervals(theTK, theInter, theNbInt, anIndex1,
|
||||
anIndex2, aCurPeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the first and the last are in neighboring periods
|
||||
if (Abs(theLPer - theFPer) == 1)
|
||||
{
|
||||
Standard_Integer aCurInt = 1;
|
||||
|
||||
if (Abs(theLastParam - theLower) < theEps)
|
||||
{
|
||||
WriteIntervals(theTK, theInter, theNbInt, anIndex1,
|
||||
theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// For period with first
|
||||
WriteIntervals(theTK, theInter, theNbInt, anIndex1,
|
||||
theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
// For period with last
|
||||
theNbIntervals++;
|
||||
WriteIntervals(theTK, theInter, theNbInt, 1,
|
||||
anIndex2, theLPer * thePeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If the first and the last are far apart
|
||||
if (Abs(theLPer - theFPer) > 1)
|
||||
{
|
||||
Standard_Integer aCurInt = 1;
|
||||
if (Abs(theLastParam - theLower) < theEps)
|
||||
{
|
||||
WriteIntervals(theTK, theInter, theNbInt, anIndex1,
|
||||
theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
|
||||
Standard_Integer aNbPer = Abs(theLPer - theFPer);
|
||||
Standard_Integer aCurPer = theFPer + 1;
|
||||
|
||||
while (aNbPer > 1)
|
||||
{
|
||||
theNbIntervals++;
|
||||
WriteIntervals(theTK, theInter, theNbInt, 1,
|
||||
theNb, aCurPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
|
||||
aNbPer--;
|
||||
aCurPer++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// For period with first
|
||||
WriteIntervals(theTK, theInter, theNbInt, anIndex1,
|
||||
theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
|
||||
Standard_Integer aNbPer = Abs(theLPer - theFPer);
|
||||
Standard_Integer aCurPer = theFPer + 1;
|
||||
while (aNbPer > 1)
|
||||
{
|
||||
theNbIntervals++;
|
||||
WriteIntervals(theTK, theInter, theNbInt, 1,
|
||||
theNb, aCurPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
|
||||
aNbPer--;
|
||||
aCurPer++;
|
||||
}
|
||||
// For period with last
|
||||
theNbIntervals++;
|
||||
WriteIntervals(theTK, theInter, theNbInt, 1,
|
||||
anIndex2, theLPer * thePeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Intervals
|
||||
//purpose :
|
||||
@@ -413,7 +924,9 @@ void Geom2dAdaptor_Curve::Intervals(TColStd_Array1OfReal& T,
|
||||
Standard_Integer FirstIndex = myBSplineCurve->FirstUKnotIndex();
|
||||
Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex();
|
||||
TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1);
|
||||
if ( S > Continuity()) {
|
||||
Standard_Boolean aContPer = (S >= Continuity()) && myBSplineCurve->IsPeriodic();
|
||||
Standard_Boolean aContNotPer = (S > Continuity()) && !myBSplineCurve->IsPeriodic();
|
||||
if (aContPer || aContNotPer) {
|
||||
Standard_Integer Cont;
|
||||
switch ( S) {
|
||||
case GeomAbs_G1:
|
||||
@@ -427,72 +940,127 @@ void Geom2dAdaptor_Curve::Intervals(TColStd_Array1OfReal& T,
|
||||
case GeomAbs_C2:
|
||||
case GeomAbs_C3:
|
||||
case GeomAbs_CN:
|
||||
{
|
||||
if ( S == GeomAbs_C1) Cont = 1;
|
||||
else if ( S == GeomAbs_C2) Cont = 2;
|
||||
else if ( S == GeomAbs_C3) Cont = 3;
|
||||
else Cont = myBSplineCurve->Degree();
|
||||
Standard_Integer Degree = myBSplineCurve->Degree();
|
||||
Standard_Integer NbKnots = myBSplineCurve->NbKnots();
|
||||
TColStd_Array1OfInteger Mults (1, NbKnots);
|
||||
myBSplineCurve->Multiplicities (Mults);
|
||||
NbSplit = 1;
|
||||
Standard_Integer Index = FirstIndex;
|
||||
Inter (NbSplit) = Index;
|
||||
{
|
||||
if (S == GeomAbs_C1) Cont = 1;
|
||||
else if (S == GeomAbs_C2) Cont = 2;
|
||||
else if (S == GeomAbs_C3) Cont = 3;
|
||||
else Cont = myBSplineCurve->Degree();
|
||||
Standard_Integer Degree = myBSplineCurve->Degree();
|
||||
Standard_Integer NbKnots = myBSplineCurve->NbKnots();
|
||||
TColStd_Array1OfInteger Mults(1, NbKnots);
|
||||
myBSplineCurve->Multiplicities(Mults);
|
||||
NbSplit = 1;
|
||||
Standard_Integer Index = FirstIndex;
|
||||
Inter(NbSplit) = Index;
|
||||
Index++;
|
||||
NbSplit++;
|
||||
while (Index < LastIndex)
|
||||
{
|
||||
if (Degree - Mults(Index) < Cont)
|
||||
{
|
||||
Inter(NbSplit) = Index;
|
||||
NbSplit++;
|
||||
}
|
||||
Index++;
|
||||
NbSplit++;
|
||||
while (Index < LastIndex)
|
||||
{
|
||||
if (Degree - Mults (Index) < Cont)
|
||||
{
|
||||
Inter (NbSplit) = Index;
|
||||
NbSplit++;
|
||||
}
|
||||
Index++;
|
||||
}
|
||||
Inter (NbSplit) = Index;
|
||||
Standard_Integer NbInt = NbSplit-1;
|
||||
|
||||
Standard_Integer Nb = myBSplineCurve->NbKnots();
|
||||
Standard_Integer Index1 = 0;
|
||||
Standard_Integer Index2 = 0;
|
||||
Standard_Real newFirst, newLast;
|
||||
TColStd_Array1OfReal TK(1,Nb);
|
||||
TColStd_Array1OfInteger TM(1,Nb);
|
||||
myBSplineCurve->Knots(TK);
|
||||
myBSplineCurve->Multiplicities(TM);
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,myFirst,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1,Nb,Index1,newFirst);
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,myLast,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1,Nb,Index2,newLast);
|
||||
}
|
||||
Inter(NbSplit) = Index;
|
||||
Standard_Integer NbInt = NbSplit - 1;
|
||||
|
||||
Standard_Integer Nb = myBSplineCurve->NbKnots();
|
||||
Standard_Integer Index1 = 0;
|
||||
Standard_Integer Index2 = 0;
|
||||
Standard_Real newFirst, newLast;
|
||||
TColStd_Array1OfReal TK(1, Nb);
|
||||
TColStd_Array1OfInteger TM(1, Nb);
|
||||
myBSplineCurve->Knots(TK);
|
||||
myBSplineCurve->Multiplicities(TM);
|
||||
Standard_Real Eps = Min(Resolution(Precision::Confusion()),
|
||||
Precision::PConfusion());
|
||||
|
||||
if (!myBSplineCurve->IsPeriodic())
|
||||
{
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myFirst,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1, Nb, Index1, newFirst);
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myLast,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1, Nb, Index2, newLast);
|
||||
|
||||
|
||||
// On decale eventuellement les indices
|
||||
// On utilise une "petite" tolerance, la resolution ne doit
|
||||
// servir que pour les tres longue courbes....(PRO9248)
|
||||
Standard_Real Eps = Min(Resolution(Precision::Confusion()),
|
||||
Precision::PConfusion());
|
||||
if ( Abs(newFirst-TK(Index1+1))< Eps) Index1++;
|
||||
if ( newLast-TK(Index2)> Eps) Index2++;
|
||||
|
||||
Inter( 1) = Index1;
|
||||
myNbIntervals = 1;
|
||||
for ( Standard_Integer i=1; i<=NbInt; i++) {
|
||||
if (Inter(i) > Index1 && Inter(i)<Index2 ) {
|
||||
myNbIntervals++;
|
||||
Inter(myNbIntervals) = Inter(i);
|
||||
}
|
||||
}
|
||||
Inter(myNbIntervals+1) = Index2;
|
||||
|
||||
Standard_Integer ii = T.Lower() - 1;
|
||||
for (Standard_Integer I=1;I<=myNbIntervals+1;I++) {
|
||||
T(ii + I) = TK(Inter(I));
|
||||
}
|
||||
}
|
||||
break;
|
||||
// On decale eventuellement les indices
|
||||
// On utilise une "petite" tolerance, la resolution ne doit
|
||||
// servir que pour les tres longue courbes....(PRO9248)
|
||||
if (Abs(newFirst - TK(Index1 + 1)) < Eps) Index1++;
|
||||
if (newLast - TK(Index2) > Eps) Index2++;
|
||||
|
||||
Inter(1) = Index1;
|
||||
myNbIntervals = 1;
|
||||
for (Standard_Integer i = 1; i <= NbInt; i++) {
|
||||
if (Inter(i) > Index1 && Inter(i) < Index2) {
|
||||
myNbIntervals++;
|
||||
Inter(myNbIntervals) = Inter(i);
|
||||
}
|
||||
}
|
||||
Inter(myNbIntervals + 1) = Index2;
|
||||
|
||||
Standard_Integer ii = T.Lower() - 1;
|
||||
for (Standard_Integer I = 1; I <= myNbIntervals + 1; I++) {
|
||||
T(ii + I) = TK(Inter(I));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Real aFirst = myFirst;
|
||||
Standard_Real aLast = myLast;
|
||||
|
||||
Standard_Real aCurFirst = aFirst;
|
||||
Standard_Real aCurLast = aLast;
|
||||
|
||||
Standard_Real aPeriod = myBSplineCurve->Period();
|
||||
Standard_Real aLower = myBSplineCurve->FirstParameter();
|
||||
Standard_Real anUpper = myBSplineCurve->LastParameter();
|
||||
|
||||
Standard_Integer aLPer = 0; Standard_Integer aFPer = 0;
|
||||
|
||||
if (Abs(myFirst - aLower) <= Eps)
|
||||
{
|
||||
aCurFirst = aLower;
|
||||
aFirst = aCurFirst;
|
||||
}
|
||||
if (Abs(myLast - anUpper) <= Eps)
|
||||
{
|
||||
aCurLast = anUpper;
|
||||
aLast = aCurLast;
|
||||
}
|
||||
|
||||
if ((Abs(aLower - myFirst) < Eps) && (aCurFirst < aLower))
|
||||
{
|
||||
aCurFirst = aLower;
|
||||
}
|
||||
else
|
||||
{
|
||||
DefinFPeriod(aLower, anUpper,
|
||||
Eps, aPeriod, aCurFirst, aFPer);
|
||||
}
|
||||
DefinLPeriod(aLower, anUpper,
|
||||
Eps, aPeriod, aCurLast, aLPer);
|
||||
|
||||
if (myFirst == aLower)
|
||||
{
|
||||
aFPer = 0;
|
||||
}
|
||||
|
||||
SpreadInt(TK, TM, Inter, myBSplineCurve->Degree(), Nb, aFPer, aLPer, NbInt, aLower, myFirst, myLast, aPeriod,
|
||||
aCurLast, Eps, T, myNbIntervals);
|
||||
T(T.Lower()) = aFirst;
|
||||
T(T.Lower() + myNbIntervals) = aLast;
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
T(T.Lower()) = myFirst;
|
||||
T(T.Lower() + myNbIntervals) = myLast;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -58,6 +58,65 @@ static const Standard_Real PosTol = Precision::PConfusion() / 2;
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(GeomAdaptor_Curve, Adaptor3d_Curve)
|
||||
|
||||
static void DefinFPeriod(const Standard_Real theLower,
|
||||
const Standard_Real theUpper,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Real thePeriod,
|
||||
Standard_Real &theCurFirst,
|
||||
Standard_Integer &theFPer);
|
||||
|
||||
static void DefinLPeriod(const Standard_Real theLower,
|
||||
const Standard_Real theUpper,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Real thePeriod,
|
||||
Standard_Real &theCurLast,
|
||||
Standard_Integer &theLPer);
|
||||
|
||||
static Standard_Integer LocalNbIntervals(const TColStd_Array1OfReal& theTK,
|
||||
const TColStd_Array1OfInteger& theTM,
|
||||
const TColStd_Array1OfInteger& theInter,
|
||||
const Standard_Integer theCurDegree,
|
||||
const Standard_Integer theNb,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Boolean thePeriodicCur,
|
||||
Standard_Integer theNbIntervals,
|
||||
Standard_Real theLower = 0,
|
||||
Standard_Real thePeriod = 0,
|
||||
Standard_Integer theIndex1 = 0,
|
||||
Standard_Integer theIndex2 = 0);
|
||||
|
||||
static void WriteIntervals(const TColStd_Array1OfReal &theTK,
|
||||
const TColStd_Array1OfInteger &theInter,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Integer theIndex1,
|
||||
const Standard_Integer theIndex2,
|
||||
const Standard_Real theCurPeriod,
|
||||
const Standard_Boolean theFlagForFirst,
|
||||
TColStd_Array1OfReal &theT,
|
||||
TColStd_Array1OfInteger &theFinalIntervals,
|
||||
Standard_Integer &theNbIntervals,
|
||||
Standard_Integer &theCurInt);
|
||||
|
||||
static void SpreadInt(const TColStd_Array1OfReal &theTK,
|
||||
const TColStd_Array1OfInteger &theTM,
|
||||
const TColStd_Array1OfInteger &theInter,
|
||||
const Standard_Integer theCurDegree,
|
||||
const Standard_Integer theNb,
|
||||
const Standard_Integer theFPer,
|
||||
const Standard_Integer theLPer,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Real theLower,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real thePeriod,
|
||||
const Standard_Real theLastParam,
|
||||
const Standard_Real theEps,
|
||||
TColStd_Array1OfReal &theT,
|
||||
Standard_Integer &theNbIntervals);
|
||||
|
||||
//=======================================================================
|
||||
//function : ShallowCopy
|
||||
//purpose :
|
||||
@@ -114,7 +173,7 @@ GeomAbs_Shape GeomAdaptor_Curve::LocalContinuity(const Standard_Real U1,
|
||||
if ( (myBSplineCurve->IsPeriodic()) && (Index1 == Nb) )
|
||||
Index1 = 1;
|
||||
|
||||
if ( Index2 - Index1 <= 0) {
|
||||
if ((Index2 - Index1 <= 0) && (!myBSplineCurve->IsPeriodic())) {
|
||||
MultMax = 100; // CN entre 2 Noeuds consecutifs
|
||||
}
|
||||
else {
|
||||
@@ -251,6 +310,159 @@ GeomAbs_Shape GeomAdaptor_Curve::Continuity() const
|
||||
return GeomAbs_CN;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DefinFPeriod
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DefinFPeriod(const Standard_Real theLower,
|
||||
const Standard_Real theUpper,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Real thePeriod,
|
||||
Standard_Real &theCurFirst,
|
||||
Standard_Integer &theFPer)
|
||||
{
|
||||
if (theCurFirst >= theLower)
|
||||
{
|
||||
while (theCurFirst >= theUpper)
|
||||
{
|
||||
theCurFirst = theCurFirst - thePeriod;
|
||||
theFPer++;
|
||||
}
|
||||
if (Abs(theUpper - theCurFirst) <= theEps)
|
||||
{
|
||||
theFPer++;
|
||||
theCurFirst = theLower;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (theCurFirst < theLower)
|
||||
{
|
||||
theCurFirst = theCurFirst + thePeriod;
|
||||
if ((Abs(theLower - theCurFirst)) > theEps)
|
||||
{
|
||||
theFPer--;
|
||||
}
|
||||
}
|
||||
|
||||
if (Abs(theUpper - theCurFirst) <= theEps)
|
||||
{
|
||||
theCurFirst = theLower;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DefinLPeriod
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DefinLPeriod(const Standard_Real theLower,
|
||||
const Standard_Real theUpper,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Real thePeriod,
|
||||
Standard_Real &theCurLast,
|
||||
Standard_Integer &theLPer)
|
||||
{
|
||||
if (theCurLast >= theLower)
|
||||
{
|
||||
if ((theCurLast >= theUpper) && (Abs(theCurLast - theUpper) <= theEps))
|
||||
{
|
||||
theCurLast = theUpper;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (theCurLast >= theUpper)
|
||||
{
|
||||
theCurLast = theCurLast - thePeriod;
|
||||
theLPer++;
|
||||
}
|
||||
if (Abs(theUpper - theCurLast) <= theEps)
|
||||
{
|
||||
theCurLast = theLower;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (theCurLast < theLower)
|
||||
{
|
||||
theCurLast = theCurLast + thePeriod;
|
||||
if (Abs(theLower - theCurLast) > theEps)
|
||||
{
|
||||
theLPer--;
|
||||
}
|
||||
}
|
||||
if ((theUpper - theCurLast) <= theEps)
|
||||
{
|
||||
theCurLast = theLower;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LocalNbIntervals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer LocalNbIntervals(const TColStd_Array1OfReal& theTK,
|
||||
const TColStd_Array1OfInteger& theTM,
|
||||
const TColStd_Array1OfInteger& theInter,
|
||||
const Standard_Integer theCurDegree,
|
||||
const Standard_Integer theNb,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real theEps,
|
||||
const Standard_Boolean thePeriodicCur,
|
||||
Standard_Integer theNbIntervals,
|
||||
Standard_Real theLower,
|
||||
Standard_Real thePeriod,
|
||||
Standard_Integer theIndex1,
|
||||
Standard_Integer theIndex2)
|
||||
{
|
||||
Standard_Real aNewFirst = theFirst;
|
||||
Standard_Real aNewLast = theLast;
|
||||
if (theIndex1 == 0)
|
||||
{
|
||||
BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theFirst,
|
||||
thePeriodicCur, 1, theNb, theIndex1, aNewFirst);
|
||||
}
|
||||
if (theIndex2 == 0)
|
||||
{
|
||||
BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theLast,
|
||||
thePeriodicCur, 1, theNb, theIndex2, aNewLast);
|
||||
}
|
||||
// Protection against theFirst = UFirst - eps, which located as ULast - eps
|
||||
if (thePeriodicCur && ((aNewLast - aNewFirst) < Precision::PConfusion()))
|
||||
{
|
||||
if (Abs(aNewLast - theLower) < Precision::PConfusion())
|
||||
{
|
||||
aNewLast += thePeriod;
|
||||
}
|
||||
else
|
||||
{
|
||||
aNewFirst -= thePeriod;
|
||||
}
|
||||
}
|
||||
|
||||
if (Abs(aNewFirst - theTK(theIndex1 + 1)) < theEps)
|
||||
{
|
||||
theIndex1++;
|
||||
}
|
||||
if ((aNewLast - theTK(theIndex2)) > theEps)
|
||||
{
|
||||
theIndex2++;
|
||||
}
|
||||
for (Standard_Integer i = 1; i <= theNbInt; i++)
|
||||
{
|
||||
if (theInter(i) > theIndex1 && theInter(i) < theIndex2) theNbIntervals++;
|
||||
}
|
||||
return theNbIntervals;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbIntervals
|
||||
//purpose :
|
||||
@@ -262,11 +474,14 @@ Standard_Integer GeomAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const
|
||||
Standard_Integer NbSplit;
|
||||
if (myTypeCurve == GeomAbs_BSplineCurve) {
|
||||
Standard_Integer FirstIndex = myBSplineCurve->FirstUKnotIndex();
|
||||
Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex();
|
||||
TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1);
|
||||
if ( S > Continuity()) {
|
||||
Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex();
|
||||
TColStd_Array1OfInteger Inter(1, LastIndex - FirstIndex + 1);
|
||||
Standard_Boolean aContPer = (S >= Continuity()) && myBSplineCurve->IsPeriodic();
|
||||
Standard_Boolean aContNotPer = (S > Continuity()) && !myBSplineCurve->IsPeriodic();
|
||||
|
||||
if(aContPer || aContNotPer) {
|
||||
Standard_Integer Cont;
|
||||
switch ( S) {
|
||||
switch (S) {
|
||||
case GeomAbs_G1:
|
||||
case GeomAbs_G2:
|
||||
throw Standard_DomainError("GeomAdaptor_Curve::NbIntervals");
|
||||
@@ -276,68 +491,168 @@ Standard_Integer GeomAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const
|
||||
break;
|
||||
case GeomAbs_C1:
|
||||
case GeomAbs_C2:
|
||||
case GeomAbs_C3:
|
||||
case GeomAbs_CN:
|
||||
case GeomAbs_C3:
|
||||
case GeomAbs_CN:
|
||||
{
|
||||
if (S == GeomAbs_C1) Cont = 1;
|
||||
else if (S == GeomAbs_C2) Cont = 2;
|
||||
else if (S == GeomAbs_C3) Cont = 3;
|
||||
else Cont = myBSplineCurve->Degree();
|
||||
Standard_Integer Degree = myBSplineCurve->Degree();
|
||||
Standard_Integer NbKnots = myBSplineCurve->NbKnots();
|
||||
TColStd_Array1OfInteger Mults(1, NbKnots);
|
||||
myBSplineCurve->Multiplicities(Mults);
|
||||
NbSplit = 1;
|
||||
Standard_Integer Index = FirstIndex;
|
||||
Inter(NbSplit) = Index;
|
||||
Index++;
|
||||
NbSplit++;
|
||||
while (Index < LastIndex)
|
||||
{
|
||||
if ( S == GeomAbs_C1) Cont = 1;
|
||||
else if ( S == GeomAbs_C2) Cont = 2;
|
||||
else if ( S == GeomAbs_C3) Cont = 3;
|
||||
else Cont = myBSplineCurve->Degree();
|
||||
Standard_Integer Degree = myBSplineCurve->Degree();
|
||||
Standard_Integer NbKnots = myBSplineCurve->NbKnots();
|
||||
TColStd_Array1OfInteger Mults (1, NbKnots);
|
||||
myBSplineCurve->Multiplicities (Mults);
|
||||
NbSplit = 1;
|
||||
Standard_Integer Index = FirstIndex;
|
||||
Inter (NbSplit) = Index;
|
||||
Index++;
|
||||
NbSplit++;
|
||||
while (Index < LastIndex)
|
||||
{
|
||||
if (Degree - Mults (Index) < Cont)
|
||||
{
|
||||
Inter (NbSplit) = Index;
|
||||
NbSplit++;
|
||||
}
|
||||
Index++;
|
||||
}
|
||||
Inter (NbSplit) = Index;
|
||||
|
||||
Standard_Integer NbInt = NbSplit-1;
|
||||
|
||||
Standard_Integer Nb = myBSplineCurve->NbKnots();
|
||||
Standard_Integer Index1 = 0;
|
||||
Standard_Integer Index2 = 0;
|
||||
Standard_Real newFirst, newLast;
|
||||
const TColStd_Array1OfReal& TK = myBSplineCurve->Knots();
|
||||
const TColStd_Array1OfInteger& TM = myBSplineCurve->Multiplicities();
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,myFirst,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1,Nb,Index1,newFirst);
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,myLast,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1,Nb,Index2,newLast);
|
||||
// Protection against myFirst = UFirst - eps, which located as ULast - eps
|
||||
if (myBSplineCurve->IsPeriodic() && (newLast - newFirst) < Precision::PConfusion())
|
||||
if (Degree - Mults(Index) < Cont)
|
||||
{
|
||||
if (Abs(newLast - myBSplineCurve->FirstParameter()) < Precision::PConfusion())
|
||||
newLast += myBSplineCurve->Period();
|
||||
else
|
||||
newFirst -= myBSplineCurve->Period();
|
||||
Inter(NbSplit) = Index;
|
||||
NbSplit++;
|
||||
}
|
||||
// On decale eventuellement les indices
|
||||
// On utilise une "petite" tolerance, la resolution ne doit
|
||||
// servir que pour les tres longue courbes....(PRO9248)
|
||||
Standard_Real Eps = Min(Resolution(Precision::Confusion()),
|
||||
Precision::PConfusion());
|
||||
if ( Abs(newFirst-TK(Index1+1))< Eps) Index1++;
|
||||
if ( newLast-TK(Index2)> Eps) Index2++;
|
||||
|
||||
myNbIntervals = 1;
|
||||
for ( Standard_Integer i=1; i<=NbInt; i++)
|
||||
if (Inter(i)>Index1 && Inter(i)<Index2) myNbIntervals++;
|
||||
Index++;
|
||||
}
|
||||
break;
|
||||
Inter(NbSplit) = Index;
|
||||
|
||||
Standard_Integer NbInt = NbSplit - 1;
|
||||
|
||||
Standard_Integer Nb = myBSplineCurve->NbKnots();
|
||||
Standard_Integer Index1 = 0;
|
||||
Standard_Integer Index2 = 0;
|
||||
const TColStd_Array1OfReal& TK = myBSplineCurve->Knots();
|
||||
const TColStd_Array1OfInteger& TM = myBSplineCurve->Multiplicities();
|
||||
Standard_Real Eps = Min(Resolution(Precision::Confusion()),
|
||||
Precision::PConfusion());
|
||||
|
||||
myNbIntervals = 1;
|
||||
|
||||
if (!myBSplineCurve->IsPeriodic())
|
||||
{
|
||||
myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
myFirst, myLast, Eps, Standard_False, myNbIntervals);
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Real aCurFirst = myFirst;
|
||||
Standard_Real aCurLast = myLast;
|
||||
Standard_Real aLower = myBSplineCurve->FirstParameter();
|
||||
Standard_Real anUpper = myBSplineCurve->LastParameter();
|
||||
|
||||
if ((Abs(aCurFirst - aLower) < Eps) && (aCurFirst < aLower))
|
||||
{
|
||||
aCurFirst = aLower;
|
||||
}
|
||||
if ((Abs(aCurLast - anUpper) < Eps) && (aCurLast < anUpper))
|
||||
{
|
||||
aCurLast = anUpper;
|
||||
}
|
||||
|
||||
Standard_Real aPeriod = myBSplineCurve->Period();
|
||||
Standard_Integer aLPer = 1; Standard_Integer aFPer = 1;
|
||||
if ((Abs(aLower - myFirst) < Eps) && (aCurFirst < aLower))
|
||||
{
|
||||
aCurFirst = aLower;
|
||||
}
|
||||
else
|
||||
{
|
||||
DefinFPeriod(aLower, anUpper,
|
||||
Eps, aPeriod, aCurFirst, aFPer);
|
||||
}
|
||||
DefinLPeriod(aLower, anUpper,
|
||||
Eps, aPeriod, aCurLast, aLPer);
|
||||
|
||||
Standard_Real aNewFirst;
|
||||
Standard_Real aNewLast;
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myFirst,
|
||||
Standard_True, 1, Nb, Index1, aNewFirst);
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myLast,
|
||||
Standard_True, 1, Nb, Index2, aNewLast);
|
||||
if ((aNewFirst == myFirst && aNewLast == myLast) && (aFPer != aLPer))
|
||||
{
|
||||
myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
myFirst, myLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod);
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Integer aSumPer = Abs(aLPer - aFPer);
|
||||
|
||||
Standard_Real aFirst = 0;
|
||||
if (aLower < 0 && anUpper == 0)
|
||||
{
|
||||
if (Abs(aCurLast) < Eps)
|
||||
{
|
||||
aCurLast = 0;
|
||||
}
|
||||
aFirst = aLower;
|
||||
}
|
||||
|
||||
if (aSumPer <= 1)
|
||||
{
|
||||
if ((Abs(myFirst - TK(Nb) - aPeriod * (aFPer - 1)) <= Eps) && (myLast < (TK(Nb) + aPeriod * (aLPer - 1))))
|
||||
{
|
||||
myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
myFirst, myLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod);
|
||||
return myNbIntervals;
|
||||
}
|
||||
if ((Abs(myFirst - aLower) < Eps) && (Abs(myLast - anUpper) < Eps))
|
||||
{
|
||||
myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
myFirst, myLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod);
|
||||
return myNbIntervals;
|
||||
}
|
||||
}
|
||||
|
||||
if (aSumPer != 0)
|
||||
{
|
||||
Standard_Integer aFInt = 0;
|
||||
Standard_Integer aLInt = 0;
|
||||
Standard_Integer aPInt = NbInt;
|
||||
|
||||
if ((aCurFirst != aPeriod) || ((aCurFirst != anUpper) && (Abs(myFirst) < Eps)))
|
||||
{
|
||||
aFInt = 1;
|
||||
}
|
||||
if ((aCurLast != aLower) && (aCurLast != anUpper))
|
||||
{
|
||||
aLInt = 1;
|
||||
}
|
||||
|
||||
aFInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
aCurFirst, anUpper, Eps, Standard_True, aFInt, aLower, aPeriod);
|
||||
|
||||
if (aCurLast == anUpper)
|
||||
{
|
||||
aLInt = NbInt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Abs(aCurLast - aFirst) > Eps)
|
||||
{
|
||||
aLInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
aFirst, aCurLast, Eps, Standard_True, aLInt, aLower, aPeriod, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
aLInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
aFirst, aCurLast, Eps, Standard_True, aLInt, aLower, aPeriod);
|
||||
}
|
||||
}
|
||||
|
||||
myNbIntervals = aFInt + aLInt + aPInt * (aSumPer - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt,
|
||||
aCurFirst, aCurLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,6 +688,206 @@ Standard_Integer GeomAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const
|
||||
return myNbIntervals;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WriteIntervals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static void WriteIntervals(const TColStd_Array1OfReal &theTK,
|
||||
const TColStd_Array1OfInteger &theInter,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Integer theIndex1,
|
||||
const Standard_Integer theIndex2,
|
||||
const Standard_Real theCurPeriod,
|
||||
const Standard_Boolean theFlagForFirst,
|
||||
TColStd_Array1OfReal &theT,
|
||||
TColStd_Array1OfInteger &theFinalIntervals,
|
||||
Standard_Integer &theNbIntervals,
|
||||
Standard_Integer &theCurInt)
|
||||
{
|
||||
if (theFlagForFirst)
|
||||
{
|
||||
for (Standard_Integer anId = 1; anId <= theNbInt; anId++)
|
||||
{
|
||||
if (theInter(anId) > theIndex1 && theInter(anId) <= theIndex2)
|
||||
{
|
||||
theNbIntervals++;
|
||||
theFinalIntervals(theNbIntervals) = theInter(anId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer anId = 1; anId <= theNbInt; anId++)
|
||||
{
|
||||
if (theInter(anId) > theIndex1 && theInter(anId) < theIndex2)
|
||||
{
|
||||
theNbIntervals++;
|
||||
theFinalIntervals(theNbIntervals) = theInter(anId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
theFinalIntervals(theNbIntervals + 1) = theIndex2;
|
||||
|
||||
for (Standard_Integer anId = theCurInt; anId <= theNbIntervals + 1; anId++)
|
||||
{
|
||||
theT(anId) = theTK(theFinalIntervals(anId)) + theCurPeriod;
|
||||
theCurInt++;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SpreadInt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SpreadInt(const TColStd_Array1OfReal &theTK,
|
||||
const TColStd_Array1OfInteger &theTM,
|
||||
const TColStd_Array1OfInteger &theInter,
|
||||
const Standard_Integer theCurDegree,
|
||||
const Standard_Integer theNb,
|
||||
const Standard_Integer theFPer,
|
||||
const Standard_Integer theLPer,
|
||||
const Standard_Integer theNbInt,
|
||||
const Standard_Real theLower,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real thePeriod,
|
||||
const Standard_Real theLastParam,
|
||||
const Standard_Real theEps,
|
||||
TColStd_Array1OfReal &theT,
|
||||
Standard_Integer &theNbIntervals)
|
||||
{
|
||||
Standard_Integer anIndex1 = 0;
|
||||
Standard_Integer anIndex2 = 0;
|
||||
Standard_Real aNewFirst, aNewLast;
|
||||
Standard_Integer anUpper;
|
||||
BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theFirst,
|
||||
Standard_True, 1, theNb, anIndex1, aNewFirst);
|
||||
BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theLastParam,
|
||||
Standard_True, 1, theNb, anIndex2, aNewLast);
|
||||
|
||||
if (Abs(aNewFirst - theTK(anIndex1 + 1)) < theEps)
|
||||
{
|
||||
anIndex1++;
|
||||
}
|
||||
if ((aNewLast - theTK(anIndex2)) > theEps)
|
||||
{
|
||||
anIndex2++;
|
||||
}
|
||||
theNbIntervals = 1;
|
||||
|
||||
if (anIndex1 == theNb)
|
||||
{
|
||||
anIndex1 = 1;
|
||||
}
|
||||
|
||||
// Count the max number of boundaries of intervals
|
||||
if (Abs(theLPer - theFPer) > 1)
|
||||
{
|
||||
anUpper = theNb - anIndex1 + anIndex2 + (theLPer - theFPer - 1) * theNb + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
anUpper = theNb - anIndex1 + anIndex2 + 1;
|
||||
}
|
||||
|
||||
if (theLPer == theFPer)
|
||||
{
|
||||
anUpper = theInter.Upper();
|
||||
}
|
||||
TColStd_Array1OfInteger aFinalIntervals(1, anUpper);
|
||||
aFinalIntervals(1) = anIndex1;
|
||||
|
||||
// If first and last are in the same period
|
||||
if ((Abs(theLPer - theFPer) == 0))
|
||||
{
|
||||
Standard_Integer aCurInt = 1;
|
||||
Standard_Real aCurPeriod = theFPer * thePeriod;
|
||||
|
||||
if (theFirst == aNewFirst && theLast == aNewLast)
|
||||
{
|
||||
aCurPeriod = 0;
|
||||
}
|
||||
WriteIntervals(theTK, theInter, theNbInt, anIndex1,
|
||||
anIndex2, aCurPeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the first and the last are in neighboring periods
|
||||
if (Abs(theLPer - theFPer) == 1)
|
||||
{
|
||||
Standard_Integer aCurInt = 1;
|
||||
|
||||
if (Abs(theLastParam - theLower) < theEps)
|
||||
{
|
||||
WriteIntervals(theTK, theInter, theNbInt, anIndex1,
|
||||
theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// For period with first
|
||||
WriteIntervals(theTK, theInter, theNbInt, anIndex1,
|
||||
theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
// For period with last
|
||||
theNbIntervals++;
|
||||
WriteIntervals(theTK, theInter, theNbInt, 1,
|
||||
anIndex2, theLPer * thePeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If the first and the last are far apart
|
||||
if (Abs(theLPer - theFPer) > 1)
|
||||
{
|
||||
Standard_Integer aCurInt = 1;
|
||||
|
||||
if (Abs(theLastParam - theLower) < theEps)
|
||||
{
|
||||
WriteIntervals(theTK, theInter, theNbInt, anIndex1,
|
||||
theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
|
||||
Standard_Integer aNbPer = Abs(theLPer - theFPer);
|
||||
Standard_Integer aCurPer = theFPer + 1;
|
||||
|
||||
while (aNbPer > 1)
|
||||
{
|
||||
theNbIntervals++;
|
||||
WriteIntervals(theTK, theInter, theNbInt, 1,
|
||||
theNb, aCurPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
|
||||
aNbPer--;
|
||||
aCurPer++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// For period with first
|
||||
WriteIntervals(theTK, theInter, theNbInt, anIndex1,
|
||||
theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
|
||||
Standard_Integer aNbPer = Abs(theLPer - theFPer);
|
||||
Standard_Integer aCurPer = theFPer + 1;
|
||||
while (aNbPer > 1)
|
||||
{
|
||||
theNbIntervals++;
|
||||
WriteIntervals(theTK, theInter, theNbInt, 1,
|
||||
theNb, aCurPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
|
||||
aNbPer--;
|
||||
aCurPer++;
|
||||
}
|
||||
// For period with last
|
||||
theNbIntervals++;
|
||||
WriteIntervals(theTK, theInter, theNbInt, 1,
|
||||
anIndex2, theLPer * thePeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Intervals
|
||||
//purpose :
|
||||
@@ -385,106 +900,166 @@ void GeomAdaptor_Curve::Intervals(TColStd_Array1OfReal& T,
|
||||
Standard_Integer NbSplit;
|
||||
Standard_Real FirstParam = myFirst, LastParam = myLast;
|
||||
|
||||
if (myTypeCurve == GeomAbs_BSplineCurve)
|
||||
{
|
||||
Standard_Integer FirstIndex = myBSplineCurve->FirstUKnotIndex();
|
||||
Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex();
|
||||
TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1);
|
||||
|
||||
if ( S > Continuity()) {
|
||||
Standard_Integer Cont;
|
||||
switch ( S) {
|
||||
case GeomAbs_G1:
|
||||
case GeomAbs_G2:
|
||||
throw Standard_DomainError("Geom2dAdaptor_Curve::NbIntervals");
|
||||
break;
|
||||
case GeomAbs_C0:
|
||||
myNbIntervals = 1;
|
||||
break;
|
||||
case GeomAbs_C1:
|
||||
case GeomAbs_C2:
|
||||
case GeomAbs_C3:
|
||||
case GeomAbs_CN:
|
||||
{
|
||||
if ( S == GeomAbs_C1) Cont = 1;
|
||||
else if ( S == GeomAbs_C2) Cont = 2;
|
||||
else if ( S == GeomAbs_C3) Cont = 3;
|
||||
else Cont = myBSplineCurve->Degree();
|
||||
Standard_Integer Degree = myBSplineCurve->Degree();
|
||||
Standard_Integer NbKnots = myBSplineCurve->NbKnots();
|
||||
TColStd_Array1OfInteger Mults (1, NbKnots);
|
||||
myBSplineCurve->Multiplicities (Mults);
|
||||
NbSplit = 1;
|
||||
Standard_Integer Index = FirstIndex;
|
||||
Inter (NbSplit) = Index;
|
||||
Index++;
|
||||
NbSplit++;
|
||||
while (Index < LastIndex)
|
||||
{
|
||||
if (Degree - Mults (Index) < Cont)
|
||||
{
|
||||
Inter (NbSplit) = Index;
|
||||
NbSplit++;
|
||||
}
|
||||
Index++;
|
||||
}
|
||||
Inter (NbSplit) = Index;
|
||||
Standard_Integer NbInt = NbSplit-1;
|
||||
// GeomConvert_BSplineCurveKnotSplitting Convector(myBspl, Cont);
|
||||
// Standard_Integer NbInt = Convector.NbSplits()-1;
|
||||
// TColStd_Array1OfInteger Inter(1,NbInt+1);
|
||||
// Convector.Splitting( Inter);
|
||||
|
||||
Standard_Integer Nb = myBSplineCurve->NbKnots();
|
||||
Standard_Integer Index1 = 0;
|
||||
Standard_Integer Index2 = 0;
|
||||
Standard_Real newFirst, newLast;
|
||||
const TColStd_Array1OfReal& TK = myBSplineCurve->Knots();
|
||||
const TColStd_Array1OfInteger& TM = myBSplineCurve->Multiplicities();
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,myFirst,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1,Nb,Index1,newFirst);
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,myLast,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1,Nb,Index2,newLast);
|
||||
FirstParam = newFirst;
|
||||
LastParam = newLast;
|
||||
// Protection against myFirst = UFirst - eps, which located as ULast - eps
|
||||
if (myBSplineCurve->IsPeriodic() && (LastParam - FirstParam) < Precision::PConfusion())
|
||||
{
|
||||
if (Abs(LastParam - myBSplineCurve->FirstParameter()) < Precision::PConfusion())
|
||||
LastParam += myBSplineCurve->Period();
|
||||
else
|
||||
FirstParam -= myBSplineCurve->Period();
|
||||
}
|
||||
// On decale eventuellement les indices
|
||||
// On utilise une "petite" tolerance, la resolution ne doit
|
||||
// servir que pour les tres longue courbes....(PRO9248)
|
||||
Standard_Real Eps = Min(Resolution(Precision::Confusion()),
|
||||
Precision::PConfusion());
|
||||
if ( Abs(FirstParam-TK(Index1+1))< Eps) Index1++;
|
||||
if ( LastParam-TK(Index2)> Eps) Index2++;
|
||||
|
||||
myNbIntervals = 1;
|
||||
if (myTypeCurve == GeomAbs_BSplineCurve)
|
||||
{
|
||||
Standard_Integer FirstIndex = myBSplineCurve->FirstUKnotIndex();
|
||||
Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex();
|
||||
TColStd_Array1OfInteger Inter(1, LastIndex - FirstIndex + 1);
|
||||
Standard_Boolean aContPer = (S >= Continuity()) && myBSplineCurve->IsPeriodic();
|
||||
Standard_Boolean aContNotPer = (S > Continuity()) && !myBSplineCurve->IsPeriodic();
|
||||
|
||||
TColStd_Array1OfInteger aFinalIntervals(1, Inter.Upper());
|
||||
aFinalIntervals(1) = Index1;
|
||||
for ( Standard_Integer i=1; i<=NbInt; i++) {
|
||||
if (Inter(i) > Index1 && Inter(i)<Index2 ) {
|
||||
myNbIntervals++;
|
||||
aFinalIntervals(myNbIntervals) = Inter(i);
|
||||
}
|
||||
}
|
||||
aFinalIntervals(myNbIntervals + 1) = Index2;
|
||||
|
||||
for (Standard_Integer I=1;I<=myNbIntervals+1;I++) {
|
||||
T(I) = TK(aFinalIntervals(I));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (aContPer || aContNotPer) {
|
||||
Standard_Integer Cont;
|
||||
switch (S) {
|
||||
case GeomAbs_G1:
|
||||
case GeomAbs_G2:
|
||||
throw Standard_DomainError("Geom2dAdaptor_Curve::NbIntervals");
|
||||
break;
|
||||
case GeomAbs_C0:
|
||||
myNbIntervals = 1;
|
||||
break;
|
||||
case GeomAbs_C1:
|
||||
case GeomAbs_C2:
|
||||
case GeomAbs_C3:
|
||||
case GeomAbs_CN:
|
||||
{
|
||||
if (S == GeomAbs_C1) Cont = 1;
|
||||
else if (S == GeomAbs_C2) Cont = 2;
|
||||
else if (S == GeomAbs_C3) Cont = 3;
|
||||
else Cont = myBSplineCurve->Degree();
|
||||
Standard_Integer Degree = myBSplineCurve->Degree();
|
||||
Standard_Integer NbKnots = myBSplineCurve->NbKnots();
|
||||
TColStd_Array1OfInteger Mults(1, NbKnots);
|
||||
myBSplineCurve->Multiplicities(Mults);
|
||||
NbSplit = 1;
|
||||
Standard_Integer Index = FirstIndex;
|
||||
Inter(NbSplit) = Index;
|
||||
Index++;
|
||||
NbSplit++;
|
||||
while (Index < LastIndex)
|
||||
{
|
||||
if (Degree - Mults(Index) < Cont)
|
||||
{
|
||||
Inter(NbSplit) = Index;
|
||||
NbSplit++;
|
||||
}
|
||||
Index++;
|
||||
}
|
||||
Inter(NbSplit) = Index;
|
||||
Standard_Integer NbInt = NbSplit - 1;
|
||||
// GeomConvert_BSplineCurveKnotSplitting Convector(myBspl, Cont);
|
||||
// Standard_Integer NbInt = Convector.NbSplits()-1;
|
||||
// TColStd_Array1OfInteger Inter(1,NbInt+1);
|
||||
// Convector.Splitting( Inter);
|
||||
|
||||
Standard_Integer Nb = myBSplineCurve->NbKnots();
|
||||
Standard_Integer Index1 = 0;
|
||||
Standard_Integer Index2 = 0;
|
||||
Standard_Real newFirst, newLast;
|
||||
const TColStd_Array1OfReal& TK = myBSplineCurve->Knots();
|
||||
const TColStd_Array1OfInteger& TM = myBSplineCurve->Multiplicities();
|
||||
Standard_Real Eps = Min(Resolution(Precision::Confusion()),
|
||||
Precision::PConfusion());
|
||||
|
||||
if (!myBSplineCurve->IsPeriodic() || ((Abs(myFirst - myBSplineCurve->FirstParameter()) < Eps) &&
|
||||
(Abs(myLast - myBSplineCurve->LastParameter()) < Eps)))
|
||||
{
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myFirst,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1, Nb, Index1, newFirst);
|
||||
BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myLast,
|
||||
myBSplineCurve->IsPeriodic(),
|
||||
1, Nb, Index2, newLast);
|
||||
FirstParam = newFirst;
|
||||
LastParam = newLast;
|
||||
// Protection against myFirst = UFirst - eps, which located as ULast - eps
|
||||
if (myBSplineCurve->IsPeriodic() && (LastParam - FirstParam) < Precision::PConfusion())
|
||||
{
|
||||
if (Abs(LastParam - myBSplineCurve->FirstParameter()) < Precision::PConfusion())
|
||||
LastParam += myBSplineCurve->Period();
|
||||
else
|
||||
FirstParam -= myBSplineCurve->Period();
|
||||
}
|
||||
// On decale eventuellement les indices
|
||||
// On utilise une "petite" tolerance, la resolution ne doit
|
||||
// servir que pour les tres longue courbes....(PRO9248)
|
||||
|
||||
if (Abs(FirstParam - TK(Index1 + 1)) < Eps) Index1++;
|
||||
if (LastParam - TK(Index2) > Eps) Index2++;
|
||||
|
||||
myNbIntervals = 1;
|
||||
|
||||
TColStd_Array1OfInteger aFinalIntervals(1, Inter.Upper());
|
||||
aFinalIntervals(1) = Index1;
|
||||
for (Standard_Integer i = 1; i <= NbInt; i++) {
|
||||
if (Inter(i) > Index1 && Inter(i) < Index2) {
|
||||
myNbIntervals++;
|
||||
aFinalIntervals(myNbIntervals) = Inter(i);
|
||||
}
|
||||
}
|
||||
aFinalIntervals(myNbIntervals + 1) = Index2;
|
||||
|
||||
for (Standard_Integer I = 1; I <= myNbIntervals + 1; I++) {
|
||||
T(I) = TK(aFinalIntervals(I));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Real aFirst = myFirst;
|
||||
Standard_Real aLast = myLast;
|
||||
|
||||
Standard_Real aCurFirst = aFirst;
|
||||
Standard_Real aCurLast = aLast;
|
||||
|
||||
Standard_Real aPeriod = myBSplineCurve->Period();
|
||||
Standard_Real aLower = myBSplineCurve->FirstParameter();
|
||||
Standard_Real anUpper = myBSplineCurve->LastParameter();
|
||||
|
||||
Standard_Integer aLPer = 0; Standard_Integer aFPer = 0;
|
||||
|
||||
if (Abs(myFirst - aLower) <= Eps)
|
||||
{
|
||||
aCurFirst = aLower;
|
||||
aFirst = aCurFirst;
|
||||
}
|
||||
|
||||
if (Abs(myLast - anUpper) <= Eps)
|
||||
{
|
||||
aCurLast = anUpper;
|
||||
aLast = aCurLast;
|
||||
}
|
||||
|
||||
if ((Abs(aLower - myFirst) < Eps) && (aCurFirst < aLower))
|
||||
{
|
||||
aCurFirst = aLower;
|
||||
}
|
||||
else
|
||||
{
|
||||
DefinFPeriod(aLower, anUpper,
|
||||
Eps, aPeriod, aCurFirst, aFPer);
|
||||
}
|
||||
DefinLPeriod(aLower, anUpper,
|
||||
Eps, aPeriod, aCurLast, aLPer);
|
||||
|
||||
if (myFirst == aLower)
|
||||
{
|
||||
aFPer = 0;
|
||||
}
|
||||
|
||||
SpreadInt(TK, TM, Inter, myBSplineCurve->Degree(), Nb, aFPer, aLPer, NbInt, aLower, myFirst, myLast, aPeriod,
|
||||
aCurLast, Eps, T, myNbIntervals);
|
||||
|
||||
T(T.Lower()) = aFirst;
|
||||
T(T.Lower() + myNbIntervals) = aLast;
|
||||
return;
|
||||
}
|
||||
}
|
||||
T(T.Lower()) = myFirst;
|
||||
T(T.Lower() + myNbIntervals) = myLast;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (myTypeCurve == GeomAbs_OffsetCurve){
|
||||
GeomAbs_Shape BaseS=GeomAbs_C0;
|
||||
|
@@ -132,7 +132,7 @@ void GeomConvert_CompCurveToBSplineCurve::Add(
|
||||
if (SecondCurve->Degree() < Deg) { SecondCurve->IncreaseDegree(Deg); }
|
||||
|
||||
// Declarationd
|
||||
Standard_Real L1, L2, U_de_raccord;
|
||||
Standard_Real L1, L2;
|
||||
Standard_Integer ii, jj;
|
||||
Standard_Real Ratio=1, Ratio1, Ratio2, Delta1, Delta2;
|
||||
Standard_Integer NbP1 = FirstCurve->NbPoles(), NbP2 = SecondCurve->NbPoles();
|
||||
@@ -159,7 +159,6 @@ void GeomConvert_CompCurveToBSplineCurve::Add(
|
||||
Delta1 = 0;
|
||||
Ratio2 = 1/Ratio;
|
||||
Delta2 = Ratio2*SecondCurve->Knot(1) - FirstCurve->Knot(NbK1);
|
||||
U_de_raccord = FirstCurve->LastParameter();
|
||||
}
|
||||
else {
|
||||
// On ne bouge pas la seconde courbe
|
||||
@@ -167,12 +166,11 @@ void GeomConvert_CompCurveToBSplineCurve::Add(
|
||||
Delta1 = Ratio1*FirstCurve->Knot(NbK1) - SecondCurve->Knot(1);
|
||||
Ratio2 = 1;
|
||||
Delta2 = 0;
|
||||
U_de_raccord = SecondCurve->FirstParameter();
|
||||
}
|
||||
|
||||
// Les Noeuds
|
||||
Standard_Real eps;
|
||||
for (ii=1; ii<NbK1; ii++) {
|
||||
for (ii=1; ii<=NbK1; ii++) {
|
||||
Noeuds(ii) = Ratio1*FirstCurve->Knot(ii) - Delta1;
|
||||
if(ii > 1) {
|
||||
eps = Epsilon (Abs(Noeuds(ii-1)));
|
||||
@@ -183,11 +181,6 @@ void GeomConvert_CompCurveToBSplineCurve::Add(
|
||||
}
|
||||
Mults(ii) = FirstCurve->Multiplicity(ii);
|
||||
}
|
||||
Noeuds(NbK1) = U_de_raccord;
|
||||
eps = Epsilon (Abs(Noeuds(NbK1-1)));
|
||||
if(Noeuds(NbK1) - Noeuds(NbK1-1) <= eps) {
|
||||
Noeuds(NbK1) += eps;
|
||||
}
|
||||
Mults(NbK1) = FirstCurve->Degree();
|
||||
for (ii=2, jj=NbK1+1; ii<=NbK2; ii++, jj++) {
|
||||
Noeuds(jj) = Ratio2*SecondCurve->Knot(ii) - Delta2;
|
||||
|
@@ -66,12 +66,14 @@ GeomFill_ConstantBiNormal::GeomFill_ConstantBiNormal(const gp_Dir& BiNormal) : B
|
||||
return copy;
|
||||
}
|
||||
|
||||
void GeomFill_ConstantBiNormal::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
Standard_Boolean GeomFill_ConstantBiNormal::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
{
|
||||
Standard_Boolean isOK = Standard_False;
|
||||
GeomFill_TrihedronLaw::SetCurve(C);
|
||||
if (! C.IsNull()) {
|
||||
frenet->SetCurve(C);
|
||||
if (! C.IsNull()) {
|
||||
isOK = frenet->SetCurve(C);
|
||||
}
|
||||
return isOK;
|
||||
}
|
||||
|
||||
Standard_Boolean GeomFill_ConstantBiNormal::D0(const Standard_Real Param,gp_Vec& Tangent,gp_Vec& Normal,gp_Vec& BiNormal)
|
||||
|
@@ -45,7 +45,9 @@ public:
|
||||
|
||||
Standard_EXPORT virtual Handle(GeomFill_TrihedronLaw) Copy() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
//! initialize curve of trihedron law
|
||||
//! @return Standard_True in case if execution end correctly
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
|
||||
//! Computes Triedrhon on curve at parameter <Param>
|
||||
Standard_EXPORT virtual Standard_Boolean D0 (const Standard_Real Param, gp_Vec& Tangent, gp_Vec& Normal, gp_Vec& BiNormal) Standard_OVERRIDE;
|
||||
|
@@ -337,34 +337,36 @@ Handle(GeomFill_TrihedronLaw) GeomFill_CorrectedFrenet::Copy() const
|
||||
return copy;
|
||||
}
|
||||
|
||||
void GeomFill_CorrectedFrenet::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
Standard_Boolean GeomFill_CorrectedFrenet::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
{
|
||||
|
||||
GeomFill_TrihedronLaw::SetCurve(C);
|
||||
if (! C.IsNull()) {
|
||||
if (! C.IsNull())
|
||||
{
|
||||
frenet->SetCurve(C);
|
||||
|
||||
GeomAbs_CurveType type;
|
||||
type = C->GetType();
|
||||
switch (type) {
|
||||
switch (type)
|
||||
{
|
||||
case GeomAbs_Circle:
|
||||
case GeomAbs_Ellipse:
|
||||
case GeomAbs_Hyperbola:
|
||||
case GeomAbs_Parabola:
|
||||
case GeomAbs_Line:
|
||||
{
|
||||
// No probleme isFrenet
|
||||
isFrenet = Standard_True;
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
// We have to search singularities
|
||||
isFrenet = Standard_True;
|
||||
Init();
|
||||
}
|
||||
{
|
||||
// No probleme isFrenet
|
||||
isFrenet = Standard_True;
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
// We have to search singularities
|
||||
isFrenet = Standard_True;
|
||||
Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
return isFrenet;
|
||||
}
|
||||
|
||||
|
||||
@@ -438,16 +440,20 @@ Handle(GeomFill_TrihedronLaw) GeomFill_CorrectedFrenet::Copy() const
|
||||
TLaw = EvolAroundT;
|
||||
//OCC78
|
||||
Standard_Integer iEnd = SeqPoles.Length();
|
||||
HArrPoles = new TColStd_HArray1OfReal(1, iEnd);
|
||||
HArrAngle = new TColStd_HArray1OfReal(1, iEnd);
|
||||
HArrTangent = new TColgp_HArray1OfVec(1, iEnd);
|
||||
HArrNormal = new TColgp_HArray1OfVec(1, iEnd);
|
||||
for(i = 1; i <= iEnd; i++){
|
||||
HArrPoles->ChangeValue(i) = SeqPoles(i);
|
||||
HArrAngle->ChangeValue(i) = SeqAngle(i);
|
||||
HArrTangent->ChangeValue(i) = SeqTangent(i);
|
||||
HArrNormal->ChangeValue(i) = SeqNormal(i);
|
||||
};
|
||||
if (iEnd != 0)
|
||||
{
|
||||
HArrPoles = new TColStd_HArray1OfReal(1, iEnd);
|
||||
HArrAngle = new TColStd_HArray1OfReal(1, iEnd);
|
||||
HArrTangent = new TColgp_HArray1OfVec(1, iEnd);
|
||||
HArrNormal = new TColgp_HArray1OfVec(1, iEnd);
|
||||
for (i = 1; i <= iEnd; i++) {
|
||||
HArrPoles->ChangeValue(i) = SeqPoles(i);
|
||||
HArrAngle->ChangeValue(i) = SeqAngle(i);
|
||||
HArrTangent->ChangeValue(i) = SeqTangent(i);
|
||||
HArrNormal->ChangeValue(i) = SeqNormal(i);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#ifdef DRAW
|
||||
if (Affich) {
|
||||
@@ -612,7 +618,7 @@ Standard_Real GeomFill_CorrectedFrenet::CalcAngleAT(const gp_Vec& Tangent, const
|
||||
Standard_Real angle;
|
||||
gp_Vec Normal_rot, cross;
|
||||
angle = Tangent.Angle(prevTangent);
|
||||
if (Abs(angle) > Precision::Angular()) {
|
||||
if (Abs(angle) > Precision::Angular() && Abs(angle) < M_PI - Precision::Angular()) {
|
||||
cross = Tangent.Crossed(prevTangent).Normalized();
|
||||
Normal_rot = Normal + sin(angle)*cross.Crossed(Normal) +
|
||||
(1 - cos(angle))*cross.Crossed(cross.Crossed(Normal));
|
||||
|
@@ -52,7 +52,9 @@ public:
|
||||
|
||||
Standard_EXPORT virtual Handle(GeomFill_TrihedronLaw) Copy() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
//! initialize curve of frenet law
|
||||
//! @return Standard_True in case if execution end correctly
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void SetInterval (const Standard_Real First, const Standard_Real Last) Standard_OVERRIDE;
|
||||
|
||||
|
@@ -63,11 +63,11 @@ Handle(GeomFill_LocationLaw) GeomFill_CurveAndTrihedron::Copy() const
|
||||
//Function: SetCurve
|
||||
//Purpose :
|
||||
//==================================================================
|
||||
void GeomFill_CurveAndTrihedron::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
Standard_Boolean GeomFill_CurveAndTrihedron::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
{
|
||||
myCurve = C;
|
||||
myTrimmed = C;
|
||||
myLaw->SetCurve(C);
|
||||
return myLaw->SetCurve(C);
|
||||
}
|
||||
|
||||
const Handle(Adaptor3d_Curve)& GeomFill_CurveAndTrihedron::GetCurve() const
|
||||
|
@@ -52,7 +52,9 @@ public:
|
||||
|
||||
Standard_EXPORT GeomFill_CurveAndTrihedron(const Handle(GeomFill_TrihedronLaw)& Trihedron);
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
//! initialize curve of trihedron law
|
||||
//! @return Standard_True in case if execution end correctly
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual const Handle(Adaptor3d_Curve)& GetCurve() const Standard_OVERRIDE;
|
||||
|
||||
|
@@ -61,33 +61,36 @@ Handle(GeomFill_TrihedronLaw) GeomFill_DiscreteTrihedron::Copy() const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomFill_DiscreteTrihedron::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
Standard_Boolean GeomFill_DiscreteTrihedron::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
{
|
||||
GeomFill_TrihedronLaw::SetCurve(C);
|
||||
if (! C.IsNull()) {
|
||||
if (! C.IsNull())
|
||||
{
|
||||
GeomAbs_CurveType type;
|
||||
type = C->GetType();
|
||||
switch (type) {
|
||||
switch (type)
|
||||
{
|
||||
case GeomAbs_Circle:
|
||||
case GeomAbs_Ellipse:
|
||||
case GeomAbs_Hyperbola:
|
||||
case GeomAbs_Parabola:
|
||||
case GeomAbs_Line:
|
||||
{
|
||||
// No problem
|
||||
myUseFrenet = Standard_True;
|
||||
myFrenet->SetCurve(C);
|
||||
break;
|
||||
}
|
||||
{
|
||||
// No problem
|
||||
myUseFrenet = Standard_True;
|
||||
myFrenet->SetCurve(C);
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
myUseFrenet = Standard_False;
|
||||
// We have to fill <myKnots> and <myTrihedrons>
|
||||
Init();
|
||||
break;
|
||||
}
|
||||
{
|
||||
myUseFrenet = Standard_False;
|
||||
// We have to fill <myKnots> and <myTrihedrons>
|
||||
Init();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return myUseFrenet;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -51,7 +51,9 @@ public:
|
||||
|
||||
Standard_EXPORT void Init();
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
//! initialize curve of trihedron law
|
||||
//! @return Standard_True in case if execution end correctly
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
|
||||
//! compute Trihedron on curve at parameter <Param>
|
||||
Standard_EXPORT virtual Standard_Boolean D0 (const Standard_Real Param, gp_Vec& Tangent, gp_Vec& Normal, gp_Vec& BiNormal) Standard_OVERRIDE;
|
||||
|
@@ -117,7 +117,7 @@ Handle(GeomFill_TrihedronLaw) GeomFill_Frenet::Copy() const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeomFill_Frenet::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
Standard_Boolean GeomFill_Frenet::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
{
|
||||
GeomFill_TrihedronLaw::SetCurve(C);
|
||||
if (! C.IsNull()) {
|
||||
@@ -141,6 +141,7 @@ Handle(GeomFill_TrihedronLaw) GeomFill_Frenet::Copy() const
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -47,7 +47,9 @@ public:
|
||||
|
||||
Standard_EXPORT void Init();
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
//! initialize curve of frenet law
|
||||
//! @return Standard_True
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
|
||||
//! compute Triedrhon on curve at parameter <Param>
|
||||
Standard_EXPORT virtual Standard_Boolean D0 (const Standard_Real Param, gp_Vec& Tangent, gp_Vec& Normal, gp_Vec& BiNormal) Standard_OVERRIDE;
|
||||
|
@@ -292,7 +292,7 @@ GeomFill_GuideTrihedronAC::GeomFill_GuideTrihedronAC(const Handle(Adaptor3d_Curv
|
||||
//function : SetCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GeomFill_GuideTrihedronAC::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
Standard_Boolean GeomFill_GuideTrihedronAC::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
{
|
||||
myCurve = C;
|
||||
myTrimmed = C;
|
||||
@@ -301,6 +301,7 @@ GeomFill_GuideTrihedronAC::GeomFill_GuideTrihedronAC(const Handle(Adaptor3d_Curv
|
||||
L = myCurveAC->GetLength();
|
||||
// CorrectOrient(myGuide);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -44,7 +44,9 @@ public:
|
||||
|
||||
Standard_EXPORT GeomFill_GuideTrihedronAC(const Handle(Adaptor3d_Curve)& guide);
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
//! initialize curve of trihedron law
|
||||
//! @return Standard_True
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Handle(GeomFill_TrihedronLaw) Copy() const Standard_OVERRIDE;
|
||||
|
||||
|
@@ -197,10 +197,11 @@ GeomFill_GuideTrihedronPlan::GeomFill_GuideTrihedronPlan (const Handle(Adaptor3d
|
||||
//function : SetCurve
|
||||
//purpose : calculation of trihedron
|
||||
//=======================================================================
|
||||
void GeomFill_GuideTrihedronPlan::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
Standard_Boolean GeomFill_GuideTrihedronPlan::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
{
|
||||
myCurve = C;
|
||||
if (!myCurve.IsNull()) Init();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -48,7 +48,9 @@ public:
|
||||
|
||||
Standard_EXPORT GeomFill_GuideTrihedronPlan(const Handle(Adaptor3d_Curve)& theGuide);
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& thePath) Standard_OVERRIDE;
|
||||
//! initialize curve of trihedron law
|
||||
//! @return Standard_True in case if execution end correctly
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& thePath) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Handle(GeomFill_TrihedronLaw) Copy() const Standard_OVERRIDE;
|
||||
|
||||
|
@@ -105,13 +105,14 @@ GeomFill_LocationDraft::GeomFill_LocationDraft
|
||||
//Purpose : Calcul des poles sur la surfaces d'arret (intersection
|
||||
// entre la generatrice et la surface en myNbPts points de la section)
|
||||
//==================================================================
|
||||
void GeomFill_LocationDraft::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
Standard_Boolean GeomFill_LocationDraft::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
{
|
||||
myCurve = C;
|
||||
myTrimmed = C;
|
||||
myLaw->SetCurve(C);
|
||||
Standard_Boolean isOK = myLaw->SetCurve(C);
|
||||
|
||||
Prepare();
|
||||
return isOK;
|
||||
}
|
||||
|
||||
//==================================================================
|
||||
|
@@ -46,7 +46,9 @@ public:
|
||||
|
||||
Standard_EXPORT void SetAngle (const Standard_Real Angle);
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
//! calculation of poles on locking surfaces (the intersection between the generatrixand the surface at the cross - section points myNbPts)
|
||||
//! @return Standard_True in case if execution end correctly
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual const Handle(Adaptor3d_Curve)& GetCurve() const Standard_OVERRIDE;
|
||||
|
||||
|
@@ -537,7 +537,7 @@ static void InGoodPeriod(const Standard_Real Prec,
|
||||
//Purpose : Calcul des poles sur la surface d'arret (intersection
|
||||
// courbe guide / surface de revolution en myNbPts points)
|
||||
//==================================================================
|
||||
void GeomFill_LocationGuide::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
Standard_Boolean GeomFill_LocationGuide::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
{
|
||||
Standard_Real LastAngle;
|
||||
myCurve = C;
|
||||
@@ -550,6 +550,7 @@ static void InGoodPeriod(const Standard_Real Prec,
|
||||
|
||||
if (rotation) SetRotation(myPoles2d->Value(1,1).X(), LastAngle);
|
||||
}
|
||||
return myStatus == GeomFill_PipeOk;
|
||||
}
|
||||
|
||||
//==================================================================
|
||||
|
@@ -56,7 +56,9 @@ public:
|
||||
|
||||
Standard_EXPORT void EraseRotation();
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
//! calculating poles on a surface (courbe guide / the surface of rotation in points myNbPts)
|
||||
//! @return Standard_True
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual const Handle(Adaptor3d_Curve)& GetCurve() const Standard_OVERRIDE;
|
||||
|
||||
|
@@ -38,9 +38,8 @@ class GeomFill_LocationLaw : public Standard_Transient
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) = 0;
|
||||
//! initialize curve of location law
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) = 0;
|
||||
|
||||
Standard_EXPORT virtual const Handle(Adaptor3d_Curve)& GetCurve() const = 0;
|
||||
|
||||
|
@@ -205,7 +205,7 @@ static Standard_Boolean CheckSense(const TColGeom_SequenceOfCurve& Seq1,
|
||||
//purpose : constructor with no parameters.
|
||||
//=======================================================================
|
||||
|
||||
GeomFill_Pipe::GeomFill_Pipe() : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
|
||||
GeomFill_Pipe::GeomFill_Pipe() : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
@@ -218,7 +218,7 @@ GeomFill_Pipe::GeomFill_Pipe() : myIsDone(Standard_False),myExchUV(Standard_Fals
|
||||
|
||||
GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
const Standard_Real Radius)
|
||||
: myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
|
||||
: myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False)
|
||||
{
|
||||
Init();
|
||||
Init(Path, Radius);
|
||||
@@ -232,7 +232,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
const Handle(Geom_Curve)& FirstSect,
|
||||
const GeomFill_Trihedron Option)
|
||||
: myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
|
||||
: myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False)
|
||||
{
|
||||
Init();
|
||||
Init(Path, FirstSect, Option);
|
||||
@@ -246,7 +246,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom2d_Curve)& Path,
|
||||
const Handle(Geom_Surface)& Support,
|
||||
const Handle(Geom_Curve)& FirstSect)
|
||||
: myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
|
||||
: myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False)
|
||||
{
|
||||
Init();
|
||||
Init(Path, Support, FirstSect);
|
||||
@@ -260,7 +260,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom2d_Curve)& Path,
|
||||
GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
const Handle(Geom_Curve)& FirstSect,
|
||||
const Handle(Geom_Curve)& LastSect)
|
||||
: myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
|
||||
: myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False)
|
||||
{
|
||||
Init();
|
||||
Init(Path, FirstSect, LastSect);
|
||||
@@ -274,7 +274,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
|
||||
GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
const TColGeom_SequenceOfCurve& NSections)
|
||||
: myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
|
||||
: myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False)
|
||||
{
|
||||
Init();
|
||||
Init(Path, NSections);
|
||||
@@ -288,7 +288,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
const Handle(Geom_Curve)& Curve1,
|
||||
const gp_Dir& Direction)
|
||||
: myIsDone(Standard_False),myExchUV(Standard_False), myKPart(Standard_False)
|
||||
: myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False), myKPart(Standard_False)
|
||||
{
|
||||
Init(Path, Curve1, Direction);
|
||||
}
|
||||
@@ -301,7 +301,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
const Handle(Geom_Curve)& Curve1,
|
||||
const Handle(Geom_Curve)& Curve2,
|
||||
const Standard_Real Radius)
|
||||
: myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
|
||||
: myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False)
|
||||
{
|
||||
Init();
|
||||
Handle(GeomAdaptor_Curve) AdpPath =
|
||||
@@ -324,7 +324,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Adaptor3d_Curve)& Path,
|
||||
const Handle(Adaptor3d_Curve)& Curve1,
|
||||
const Handle(Adaptor3d_Curve)& Curve2,
|
||||
const Standard_Real Radius)
|
||||
: myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
|
||||
: myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False)
|
||||
{
|
||||
Init();
|
||||
Init(Path,Curve1,Curve2,Radius);
|
||||
@@ -344,7 +344,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
|
||||
const Handle(Geom_Curve)& FirstSect,
|
||||
const Standard_Boolean byACR,
|
||||
const Standard_Boolean rotat)
|
||||
: myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
|
||||
: myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False)
|
||||
// Path : trajectoire
|
||||
// Guide : courbe guide
|
||||
// FirstSect : section
|
||||
@@ -751,31 +751,37 @@ void GeomFill_Pipe::Init(const Handle(Geom_Curve)& Path,
|
||||
|
||||
if (!TLaw.IsNull()) {
|
||||
myLoc = new (GeomFill_CurveAndTrihedron) (TLaw);
|
||||
myLoc->SetCurve(myAdpPath);
|
||||
TColGeom_SequenceOfCurve SeqC;
|
||||
TColStd_SequenceOfReal SeqP;
|
||||
SeqC.Clear();
|
||||
SeqP.Clear();
|
||||
// sequence des sections
|
||||
GeomFill_SectionPlacement Pl1(myLoc, FirstSect);
|
||||
Pl1.Perform(first,Precision::Confusion());
|
||||
SeqC.Append(Pl1.Section(Standard_False));
|
||||
GeomFill_SectionPlacement Pl2(myLoc, LastSect);
|
||||
Pl2.Perform(first,Precision::Confusion());
|
||||
SeqC.Append(Pl2.Section(Standard_False));
|
||||
// sequence des parametres associes
|
||||
SeqP.Append(first);
|
||||
SeqP.Append(last);
|
||||
|
||||
// verification de l'orientation
|
||||
TColGeom_SequenceOfCurve NewSeq;
|
||||
if (CheckSense(SeqC,NewSeq)) SeqC = NewSeq;
|
||||
if (!(myLoc->SetCurve(myAdpPath)))
|
||||
{
|
||||
myStatus = GeomFill_ImpossibleContact;
|
||||
return;
|
||||
}
|
||||
|
||||
// creation de la NSections
|
||||
Standard_Real deb,fin;
|
||||
deb = SeqC.First()->FirstParameter();
|
||||
fin = SeqC.First()->LastParameter();
|
||||
mySec = new (GeomFill_NSections) (SeqC,SeqP,deb,fin,first,last);
|
||||
TColGeom_SequenceOfCurve SeqC;
|
||||
TColStd_SequenceOfReal SeqP;
|
||||
SeqC.Clear();
|
||||
SeqP.Clear();
|
||||
// sequence of sections
|
||||
GeomFill_SectionPlacement Pl1(myLoc, FirstSect);
|
||||
Pl1.Perform(first, Precision::Confusion());
|
||||
SeqC.Append(Pl1.Section(Standard_False));
|
||||
GeomFill_SectionPlacement Pl2(myLoc, LastSect);
|
||||
Pl2.Perform(first, Precision::Confusion());
|
||||
SeqC.Append(Pl2.Section(Standard_False));
|
||||
// sequence of associated parameters
|
||||
SeqP.Append(first);
|
||||
SeqP.Append(last);
|
||||
|
||||
// orientation verification
|
||||
TColGeom_SequenceOfCurve NewSeq;
|
||||
if (CheckSense(SeqC, NewSeq)) SeqC = NewSeq;
|
||||
|
||||
// creation of the NSections
|
||||
Standard_Real deb, fin;
|
||||
deb = SeqC.First()->FirstParameter();
|
||||
fin = SeqC.First()->LastParameter();
|
||||
mySec = new (GeomFill_NSections) (SeqC, SeqP, deb, fin, first, last);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,6 +837,11 @@ void GeomFill_Pipe::Perform(const Standard_Real Tol,
|
||||
const Standard_Integer DegMax,
|
||||
const Standard_Integer NbMaxSegment)
|
||||
{
|
||||
if (myStatus == GeomFill_ImpossibleContact)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GeomAbs_Shape TheConti;
|
||||
switch (Conti) {
|
||||
case GeomAbs_C0:
|
||||
@@ -884,7 +895,7 @@ void GeomFill_Pipe::Perform(const Standard_Real Tol,
|
||||
App.UDegree(),
|
||||
App.VDegree());
|
||||
myError = App.MaxErrorOnSurf();
|
||||
myIsDone = Standard_True;
|
||||
myStatus = GeomFill_PipeOk;
|
||||
}
|
||||
//else {
|
||||
// throw Standard_ConstructionError("GeomFill_Pipe::Perform : Cannot make a surface");
|
||||
@@ -898,7 +909,7 @@ void GeomFill_Pipe::Perform(const Standard_Real Tol,
|
||||
if (Sweep.IsDone()) {
|
||||
mySurface = Sweep.Surface();
|
||||
myError = Sweep.ErrorOnSurface();
|
||||
myIsDone = Standard_True;
|
||||
myStatus = GeomFill_PipeOk;
|
||||
}
|
||||
//else {
|
||||
// throw Standard_ConstructionError("GeomFill_Pipe::Perform : Cannot make a surface");
|
||||
@@ -975,7 +986,7 @@ Standard_Boolean GeomFill_Pipe::KPartT4()
|
||||
myAdpPath->FirstParameter(),
|
||||
myAdpPath->LastParameter());
|
||||
Ok = Standard_True; //C'est bien un cylindre
|
||||
myIsDone = Standard_True;
|
||||
myStatus = GeomFill_PipeOk;
|
||||
}
|
||||
// ----------- Cas du tore ----------------------------------
|
||||
else if (myAdpPath->GetType() == GeomAbs_Circle &&
|
||||
@@ -1038,7 +1049,7 @@ Standard_Boolean GeomFill_Pipe::KPartT4()
|
||||
myAdpPath->FirstParameter(),myAdpPath->LastParameter(),VV1,VV2);
|
||||
myExchUV = Standard_True;
|
||||
Ok = Standard_True;
|
||||
myIsDone = Standard_True;
|
||||
myStatus = GeomFill_PipeOk;
|
||||
}
|
||||
|
||||
return Ok;
|
||||
@@ -1137,6 +1148,6 @@ void GeomFill_Pipe::ApproxSurf(const Standard_Boolean WithParameters) {
|
||||
App.VDegree());
|
||||
Standard_Real t2d;
|
||||
App.TolReached(myError, t2d);
|
||||
myIsDone = Standard_True;
|
||||
myStatus = GeomFill_PipeOk;
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <GeomFill_Trihedron.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <TColGeom_SequenceOfCurve.hxx>
|
||||
#include <GeomFill_PipeError.hxx>
|
||||
|
||||
class Geom_Surface;
|
||||
class GeomFill_LocationLaw;
|
||||
@@ -249,7 +250,11 @@ public:
|
||||
//! Returns whether approximation was done.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
|
||||
//! Returns execution status
|
||||
GeomFill_PipeError GetStatus() const
|
||||
{
|
||||
return myStatus;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -271,8 +276,7 @@ private:
|
||||
|
||||
Standard_EXPORT Standard_Boolean KPartT4();
|
||||
|
||||
|
||||
Standard_Boolean myIsDone;
|
||||
GeomFill_PipeError myStatus;//!< Execution status
|
||||
Standard_Real myRadius;
|
||||
Standard_Real myError;
|
||||
Handle(Adaptor3d_Curve) myAdpPath;
|
||||
@@ -285,8 +289,6 @@ private:
|
||||
Standard_Boolean myExchUV;
|
||||
Standard_Boolean myKPart;
|
||||
Standard_Boolean myPolynomial;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@@ -70,6 +70,5 @@ inline Standard_Real GeomFill_Pipe::ErrorOnSurf() const
|
||||
//=======================================================================
|
||||
inline Standard_Boolean GeomFill_Pipe::IsDone() const
|
||||
{
|
||||
return myIsDone;
|
||||
return myStatus == GeomFill_PipeOk;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -24,10 +24,11 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(GeomFill_TrihedronLaw,Standard_Transient)
|
||||
|
||||
void GeomFill_TrihedronLaw::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
Standard_Boolean GeomFill_TrihedronLaw::SetCurve(const Handle(Adaptor3d_Curve)& C)
|
||||
{
|
||||
myCurve = C;
|
||||
myTrimmed = myCurve;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//==================================================================
|
||||
|
@@ -34,8 +34,9 @@ class GeomFill_TrihedronLaw : public Standard_Transient
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C);
|
||||
//! initialize curve of trihedron law
|
||||
//! @return Standard_True
|
||||
Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C);
|
||||
|
||||
Standard_EXPORT virtual Handle(GeomFill_TrihedronLaw) Copy() const = 0;
|
||||
|
||||
|
@@ -77,38 +77,78 @@ void GeomInt_IntSS::Perform(const Handle(Geom_Surface)& S1,
|
||||
myTolReached2d = myTolReached3d = 0.0;
|
||||
myNbrestr = 0;
|
||||
sline.Clear();
|
||||
Handle(Adaptor3d_TopolTool) dom1 = new Adaptor3d_TopolTool(myHS1);
|
||||
Handle(Adaptor3d_TopolTool) dom2 = new Adaptor3d_TopolTool(myHS2);
|
||||
myLConstruct.Load(dom1,dom2,myHS1,myHS2);
|
||||
|
||||
Standard_Real TolArc = Tol;
|
||||
Standard_Real TolTang = Tol;
|
||||
Standard_Real UVMaxStep = IntPatch_Intersection::DefineUVMaxStep(myHS1, dom1, myHS2, dom2);
|
||||
Standard_Real Deflection = 0.1;
|
||||
if (myHS1->GetType() == GeomAbs_BSplineSurface && myHS2->GetType() == GeomAbs_BSplineSurface)
|
||||
{
|
||||
Deflection /= 10.;
|
||||
}
|
||||
|
||||
Handle(Adaptor3d_TopolTool) dom1 = new Adaptor3d_TopolTool (myHS1);
|
||||
Handle(Adaptor3d_TopolTool) dom2 = new Adaptor3d_TopolTool (myHS2);
|
||||
|
||||
myIntersector.SetTolerances(TolArc,TolTang,UVMaxStep,Deflection);
|
||||
NCollection_Vector< Handle(Adaptor3d_Surface)> aVecHS1;
|
||||
NCollection_Vector< Handle(Adaptor3d_Surface)> aVecHS2;
|
||||
|
||||
if(myHS1 == myHS2) {
|
||||
myIntersector.Perform(myHS1,dom1,TolArc,TolTang);
|
||||
if (myHS1 == myHS2)
|
||||
{
|
||||
aVecHS1.Append (myHS1);
|
||||
aVecHS2.Append (myHS2);
|
||||
}
|
||||
else if (!useStart) {
|
||||
myIntersector.Perform(myHS1,dom1,myHS2,dom2,TolArc,TolTang);
|
||||
}
|
||||
else {
|
||||
myIntersector.Perform(myHS1,dom1,myHS2,dom2,U1,V1,U2,V2,TolArc,TolTang);
|
||||
else
|
||||
{
|
||||
myIntersector.PrepareSurfaces (myHS1, dom1, myHS2, dom2, Tol, aVecHS1, aVecHS2);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
if (myIntersector.IsDone()) {
|
||||
const Standard_Integer nblin = myIntersector.NbLines();
|
||||
for (Standard_Integer i=1; i<= nblin; i++)
|
||||
for (Standard_Integer aNumOfHS1 = 0; aNumOfHS1 < aVecHS1.Length(); aNumOfHS1++)
|
||||
{
|
||||
const Handle(Adaptor3d_Surface)& aHS1 = aVecHS1.Value (aNumOfHS1);
|
||||
|
||||
for (Standard_Integer aNumOfHS2 = 0; aNumOfHS2 < aVecHS2.Length(); aNumOfHS2++)
|
||||
{
|
||||
MakeCurve(i,dom1,dom2,Tol,Approx,ApproxS1,ApproxS2);
|
||||
const Handle(Adaptor3d_Surface)& aHS2 = aVecHS2.Value (aNumOfHS2);
|
||||
|
||||
Handle(Adaptor3d_TopolTool) aDom1 = new Adaptor3d_TopolTool (aHS1);
|
||||
Handle(Adaptor3d_TopolTool) aDom2 = new Adaptor3d_TopolTool (aHS2);
|
||||
|
||||
myLConstruct.Load (aDom1 ,aDom2,
|
||||
Handle(GeomAdaptor_Surface)::DownCast (aHS1),
|
||||
Handle(GeomAdaptor_Surface)::DownCast (aHS2));
|
||||
|
||||
Standard_Real UVMaxStep = IntPatch_Intersection::DefineUVMaxStep (aHS1, aDom1, aHS2, aDom2);
|
||||
|
||||
myIntersector.SetTolerances (TolArc, TolTang, UVMaxStep, Deflection);
|
||||
|
||||
if (aHS1 == aHS2)
|
||||
{
|
||||
myIntersector.Perform (aHS1, aDom1, TolArc, TolTang);
|
||||
}
|
||||
else if (!useStart)
|
||||
{
|
||||
myIntersector.Perform (aHS1, aDom1, aHS2, aDom2, TolArc, TolTang);
|
||||
}
|
||||
else
|
||||
{
|
||||
TopAbs_State aState1 = aDom1->Classify (gp_Pnt2d (U1, V1), Tol);
|
||||
TopAbs_State aState2 = aDom2->Classify (gp_Pnt2d (U2, V2), Tol);
|
||||
|
||||
if ((aState1 == TopAbs_IN || aState1 == TopAbs_ON) &&
|
||||
(aState2 == TopAbs_IN || aState2 == TopAbs_ON))
|
||||
{
|
||||
myIntersector.Perform (aHS1, aDom1, aHS2, aDom2, U1, V1, U2, V2, TolArc, TolTang);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
if (myIntersector.IsDone()) {
|
||||
const Standard_Integer nblin = myIntersector.NbLines();
|
||||
for (Standard_Integer i = 1; i <= nblin; i++)
|
||||
{
|
||||
MakeCurve (i, aDom1, aDom2, Tol, Approx, ApproxS1, ApproxS2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2371,119 +2371,143 @@ void GeomLib::CancelDenominatorDerivative(Handle(Geom_BSplineSurface) &
|
||||
|
||||
//=======================================================================
|
||||
//function : NormEstim
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer GeomLib::NormEstim(const Handle(Geom_Surface)& S,
|
||||
const gp_Pnt2d& UV,
|
||||
const Standard_Real Tol, gp_Dir& N)
|
||||
Standard_Integer GeomLib::NormEstim (const Handle(Geom_Surface)& theSurf,
|
||||
const gp_Pnt2d& theUV,
|
||||
const Standard_Real theTol,
|
||||
gp_Dir& theNorm)
|
||||
{
|
||||
const Standard_Real aTol2 = Square (theTol);
|
||||
|
||||
gp_Vec DU, DV;
|
||||
gp_Pnt DummyPnt;
|
||||
Standard_Real aTol2 = Square(Tol);
|
||||
gp_Pnt aDummyPnt;
|
||||
theSurf->D1 (theUV.X(), theUV.Y(), aDummyPnt, DU, DV);
|
||||
|
||||
S->D1(UV.X(), UV.Y(), DummyPnt, DU, DV);
|
||||
|
||||
Standard_Real MDU = DU.SquareMagnitude(), MDV = DV.SquareMagnitude();
|
||||
|
||||
if(MDU >= aTol2 && MDV >= aTol2) {
|
||||
gp_Vec Norm = DU^DV;
|
||||
Standard_Real Magn = Norm.SquareMagnitude();
|
||||
if(Magn < aTol2) return 3;
|
||||
|
||||
//Magn = sqrt(Magn);
|
||||
N.SetXYZ(Norm.XYZ());
|
||||
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
gp_Vec D2U, D2V, D2UV;
|
||||
Standard_Boolean isDone;
|
||||
CSLib_NormalStatus aStatus;
|
||||
gp_Dir aNormal;
|
||||
|
||||
S->D2(UV.X(), UV.Y(), DummyPnt, DU, DV, D2U, D2V, D2UV);
|
||||
CSLib::Normal(DU, DV, D2U, D2V, D2UV, Tol, isDone, aStatus, aNormal);
|
||||
|
||||
if (isDone) {
|
||||
Standard_Real Umin, Umax, Vmin, Vmax;
|
||||
Standard_Real step = 1.0e-5;
|
||||
Standard_Real eps = 1.0e-16;
|
||||
Standard_Real sign = -1.0;
|
||||
|
||||
S->Bounds(Umin, Umax, Vmin, Vmax);
|
||||
|
||||
// check for cone apex singularity point
|
||||
if ((UV.Y() > Vmin + step) && (UV.Y() < Vmax - step))
|
||||
{
|
||||
gp_Dir aNormal1, aNormal2;
|
||||
Standard_Real aConeSingularityAngleEps = 1.0e-4;
|
||||
S->D1(UV.X(), UV.Y() - sign * step, DummyPnt, DU, DV);
|
||||
if ((DU.XYZ().SquareModulus() > eps) && (DV.XYZ().SquareModulus() > eps)) {
|
||||
aNormal1 = DU^DV;
|
||||
S->D1(UV.X(), UV.Y() + sign * step, DummyPnt, DU, DV);
|
||||
if ((DU.XYZ().SquareModulus() > eps) && (DV.XYZ().SquareModulus() > eps)) {
|
||||
aNormal2 = DU^DV;
|
||||
if (aNormal1.IsOpposite(aNormal2, aConeSingularityAngleEps))
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Along V
|
||||
if(MDU < aTol2 && MDV >= aTol2) {
|
||||
if ((Vmax - UV.Y()) > (UV.Y() - Vmin))
|
||||
sign = 1.0;
|
||||
S->D1(UV.X(), UV.Y() + sign * step, DummyPnt, DU, DV);
|
||||
gp_Vec Norm = DU^DV;
|
||||
if (Norm.SquareMagnitude() < eps) {
|
||||
Standard_Real sign1 = -1.0;
|
||||
if ((Umax - UV.X()) > (UV.X() - Umin))
|
||||
sign1 = 1.0;
|
||||
S->D1(UV.X() + sign1 * step, UV.Y() + sign * step, DummyPnt, DU, DV);
|
||||
Norm = DU^DV;
|
||||
}
|
||||
if ((Norm.SquareMagnitude() >= eps) && (Norm.Dot(aNormal) < 0.0))
|
||||
aNormal.Reverse();
|
||||
}
|
||||
|
||||
// Along U
|
||||
if(MDV < aTol2 && MDU >= aTol2) {
|
||||
if ((Umax - UV.X()) > (UV.X() - Umin))
|
||||
sign = 1.0;
|
||||
S->D1(UV.X() + sign * step, UV.Y(), DummyPnt, DU, DV);
|
||||
gp_Vec Norm = DU^DV;
|
||||
if (Norm.SquareMagnitude() < eps) {
|
||||
Standard_Real sign1 = -1.0;
|
||||
if ((Vmax - UV.Y()) > (UV.Y() - Vmin))
|
||||
sign1 = 1.0;
|
||||
S->D1(UV.X() + sign * step, UV.Y() + sign1 * step, DummyPnt, DU, DV);
|
||||
Norm = DU^DV;
|
||||
}
|
||||
if ((Norm.SquareMagnitude() >= eps) && (Norm.Dot(aNormal) < 0.0))
|
||||
aNormal.Reverse();
|
||||
}
|
||||
|
||||
// quasysingular
|
||||
if ((aStatus == CSLib_D1NuIsNull) || (aStatus == CSLib_D1NvIsNull) ||
|
||||
(aStatus == CSLib_D1NuIsParallelD1Nv)) {
|
||||
N.SetXYZ(aNormal.XYZ());
|
||||
return 1;
|
||||
}
|
||||
// conical
|
||||
if (aStatus == CSLib_InfinityOfSolutions)
|
||||
return 2;
|
||||
}
|
||||
// computation is impossible
|
||||
else {
|
||||
// conical
|
||||
if (aStatus == CSLib_D1NIsNull) {
|
||||
return 2;
|
||||
}
|
||||
const Standard_Real MDU = DU.SquareMagnitude(), MDV = DV.SquareMagnitude();
|
||||
if (MDU >= aTol2
|
||||
&& MDV >= aTol2)
|
||||
{
|
||||
gp_Vec aNorm = DU ^ DV;
|
||||
Standard_Real aMagn = aNorm.SquareMagnitude();
|
||||
if (aMagn < aTol2)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
theNorm.SetXYZ (aNorm.XYZ());
|
||||
return 0;
|
||||
}
|
||||
return 3;
|
||||
|
||||
gp_Vec D2U, D2V, D2UV;
|
||||
Standard_Boolean isDone = false;
|
||||
CSLib_NormalStatus aStatus;
|
||||
gp_Dir aNormal;
|
||||
|
||||
theSurf->D2 (theUV.X(), theUV.Y(), aDummyPnt, DU, DV, D2U, D2V, D2UV);
|
||||
CSLib::Normal (DU, DV, D2U, D2V, D2UV, theTol, isDone, aStatus, aNormal);
|
||||
if (!isDone)
|
||||
{
|
||||
// computation is impossible
|
||||
return aStatus == CSLib_D1NIsNull ? 2 : 3;
|
||||
}
|
||||
|
||||
Standard_Real Umin, Umax, Vmin, Vmax;
|
||||
Standard_Real step = 1.0e-5;
|
||||
Standard_Real eps = 1.0e-16;
|
||||
Standard_Real sign = -1.0;
|
||||
theSurf->Bounds (Umin, Umax, Vmin, Vmax);
|
||||
|
||||
// check for cone apex singularity point
|
||||
if ((theUV.Y() > Vmin + step)
|
||||
&& (theUV.Y() < Vmax - step))
|
||||
{
|
||||
gp_Dir aNormal1, aNormal2;
|
||||
Standard_Real aConeSingularityAngleEps = 1.0e-4;
|
||||
theSurf->D1(theUV.X(), theUV.Y() - sign * step, aDummyPnt, DU, DV);
|
||||
if ((DU.XYZ().SquareModulus() > eps) && (DV.XYZ().SquareModulus() > eps))
|
||||
{
|
||||
aNormal1 = DU ^ DV;
|
||||
theSurf->D1 (theUV.X(), theUV.Y() + sign * step, aDummyPnt, DU, DV);
|
||||
if ((DU.XYZ().SquareModulus() > eps)
|
||||
&& (DV.XYZ().SquareModulus() > eps))
|
||||
{
|
||||
aNormal2 = DU^DV;
|
||||
if (aNormal1.IsOpposite (aNormal2, aConeSingularityAngleEps))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Along V
|
||||
if (MDU < aTol2
|
||||
&& MDV >= aTol2)
|
||||
{
|
||||
if ((Vmax - theUV.Y()) > (theUV.Y() - Vmin))
|
||||
{
|
||||
sign = 1.0;
|
||||
}
|
||||
|
||||
theSurf->D1 (theUV.X(), theUV.Y() + sign * step, aDummyPnt, DU, DV);
|
||||
gp_Vec Norm = DU ^ DV;
|
||||
if (Norm.SquareMagnitude() < eps)
|
||||
{
|
||||
Standard_Real sign1 = -1.0;
|
||||
if ((Umax - theUV.X()) > (theUV.X() - Umin))
|
||||
{
|
||||
sign1 = 1.0;
|
||||
}
|
||||
theSurf->D1 (theUV.X() + sign1 * step, theUV.Y() + sign * step, aDummyPnt, DU, DV);
|
||||
Norm = DU ^ DV;
|
||||
}
|
||||
if (Norm.SquareMagnitude() >= eps
|
||||
&& Norm.Dot (aNormal) < 0.0)
|
||||
{
|
||||
aNormal.Reverse();
|
||||
}
|
||||
}
|
||||
|
||||
// Along U
|
||||
if (MDV < aTol2
|
||||
&& MDU >= aTol2)
|
||||
{
|
||||
if ((Umax - theUV.X()) > (theUV.X() - Umin))
|
||||
{
|
||||
sign = 1.0;
|
||||
}
|
||||
|
||||
theSurf->D1 (theUV.X() + sign * step, theUV.Y(), aDummyPnt, DU, DV);
|
||||
gp_Vec Norm = DU ^ DV;
|
||||
if (Norm.SquareMagnitude() < eps)
|
||||
{
|
||||
Standard_Real sign1 = -1.0;
|
||||
if ((Vmax - theUV.Y()) > (theUV.Y() - Vmin))
|
||||
{
|
||||
sign1 = 1.0;
|
||||
}
|
||||
|
||||
theSurf->D1 (theUV.X() + sign * step, theUV.Y() + sign1 * step, aDummyPnt, DU, DV);
|
||||
Norm = DU ^ DV;
|
||||
}
|
||||
if (Norm.SquareMagnitude() >= eps
|
||||
&& Norm.Dot (aNormal) < 0.0)
|
||||
{
|
||||
aNormal.Reverse();
|
||||
}
|
||||
}
|
||||
|
||||
// quasysingular
|
||||
if (aStatus == CSLib_D1NuIsNull
|
||||
|| aStatus == CSLib_D1NvIsNull
|
||||
|| aStatus == CSLib_D1NuIsParallelD1Nv)
|
||||
{
|
||||
theNorm.SetXYZ (aNormal.XYZ());
|
||||
return 1;
|
||||
}
|
||||
|
||||
return aStatus == CSLib_InfinityOfSolutions ? 2 : 3;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -183,8 +183,19 @@ public:
|
||||
//! Cancel,on the boundaries,the denominator first derivative
|
||||
//! in the directions wished by the user and set its value to 1.
|
||||
Standard_EXPORT static void CancelDenominatorDerivative (Handle(Geom_BSplineSurface)& BSurf, const Standard_Boolean UDirection, const Standard_Boolean VDirection);
|
||||
|
||||
Standard_EXPORT static Standard_Integer NormEstim (const Handle(Geom_Surface)& S, const gp_Pnt2d& UV, const Standard_Real Tol, gp_Dir& N);
|
||||
|
||||
//! Estimate surface normal at the given (U, V) point.
|
||||
//! @param[in] theSurf input surface
|
||||
//! @param[in] theUV (U, V) point coordinates on the surface
|
||||
//! @param[in] theTol estimation tolerance
|
||||
//! @param[out] theNorm computed normal
|
||||
//! @return 0 if normal estimated from D1,
|
||||
//! 1 if estimated from D2 (quasysingular),
|
||||
//! >=2 in case of failure (undefined or infinite solutions)
|
||||
Standard_EXPORT static Standard_Integer NormEstim (const Handle(Geom_Surface)& theSurf,
|
||||
const gp_Pnt2d& theUV,
|
||||
const Standard_Real theTol,
|
||||
gp_Dir& theNorm);
|
||||
|
||||
//! This method defines if opposite boundaries of surface
|
||||
//! coincide with given tolerance
|
||||
|
@@ -237,8 +237,8 @@ static Standard_Integer tuyau (Draw_Interpretor& di,
|
||||
|
||||
Pipe.Perform(1.e-4, Standard_False, Cont);
|
||||
if (!Pipe.IsDone()) {
|
||||
di << "GeomFill_Pipe cannot make a surface\n";
|
||||
return 1;
|
||||
di << "Error: GeomFill_Pipe cannot make a surface\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Standard_Real Accuracy = Pipe.ErrorOnSurf();
|
||||
|
@@ -941,6 +941,36 @@ static Standard_Integer value (Draw_Interpretor& ,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : derivative
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer derivative(Draw_Interpretor&,
|
||||
Standard_Integer theArgc,
|
||||
const char** theArgv)
|
||||
{
|
||||
if (theArgc != 9)
|
||||
return 1;
|
||||
|
||||
Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theArgv[1]);
|
||||
if (aSurf.IsNull())
|
||||
return 1;
|
||||
|
||||
Standard_Real aU = Draw::Atof(theArgv[2]);
|
||||
Standard_Real aV = Draw::Atof(theArgv[3]);
|
||||
Standard_Integer aNu = Draw::Atoi(theArgv[4]);
|
||||
Standard_Integer aNv = Draw::Atoi(theArgv[5]);
|
||||
|
||||
gp_Vec aDeriv = aSurf->DN(aU, aV, aNu, aNv);
|
||||
|
||||
Draw::Set(theArgv[6], aDeriv.X());
|
||||
Draw::Set(theArgv[7], aDeriv.Y());
|
||||
Draw::Set(theArgv[8], aDeriv.Z());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : movepole
|
||||
//purpose :
|
||||
@@ -1851,6 +1881,15 @@ void GeomliteTest::SurfaceCommands(Draw_Interpretor& theCommands)
|
||||
__FILE__,
|
||||
value,g);
|
||||
|
||||
theCommands.Add("sderivative",
|
||||
"sderivative surfname U V NU NV X Y Z\n"
|
||||
" surfname : name of surface\n"
|
||||
" U V : coordinates on probe point on surface\n"
|
||||
" NU NV : order of derivative along U and V\n"
|
||||
" X Y Z : output coordinates of the derivative",
|
||||
__FILE__,
|
||||
derivative, g);
|
||||
|
||||
theCommands.Add("parameters",
|
||||
"parameters surf/curve X Y [Z] Tol U [V] : {X Y Z} point, {U V} output parameter(s)",
|
||||
__FILE__,
|
||||
|
@@ -154,10 +154,11 @@ Graphic3d_Texture1Dsegment.cxx
|
||||
Graphic3d_Texture1Dsegment.hxx
|
||||
Graphic3d_Texture2D.cxx
|
||||
Graphic3d_Texture2D.hxx
|
||||
Graphic3d_Texture2Dmanual.cxx
|
||||
Graphic3d_Texture2Dmanual.hxx
|
||||
Graphic3d_Texture2Dplane.cxx
|
||||
Graphic3d_Texture2Dplane.hxx
|
||||
Graphic3d_Texture3D.cxx
|
||||
Graphic3d_Texture3D.hxx
|
||||
Graphic3d_TextureEnv.cxx
|
||||
Graphic3d_TextureEnv.hxx
|
||||
Graphic3d_TextureMap.cxx
|
||||
|
@@ -15,3 +15,40 @@
|
||||
#include <Graphic3d_CubeMap.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CubeMap, Graphic3d_TextureMap)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMap::Graphic3d_CubeMap (const TCollection_AsciiString& theFileName,
|
||||
Standard_Boolean theToGenerateMipmaps)
|
||||
: Graphic3d_TextureMap (theFileName, Graphic3d_TypeOfTexture_CUBEMAP),
|
||||
myCurrentSide (Graphic3d_CMS_POS_X),
|
||||
myEndIsReached (false),
|
||||
myZIsInverted (false)
|
||||
{
|
||||
myHasMipmaps = theToGenerateMipmaps;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMap::Graphic3d_CubeMap (const Handle(Image_PixMap)& thePixmap,
|
||||
Standard_Boolean theToGenerateMipmaps)
|
||||
: Graphic3d_TextureMap (thePixmap, Graphic3d_TypeOfTexture_CUBEMAP),
|
||||
myCurrentSide (Graphic3d_CMS_POS_X),
|
||||
myEndIsReached (false),
|
||||
myZIsInverted (false)
|
||||
{
|
||||
myHasMipmaps = theToGenerateMipmaps;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ~Graphic3d_CubeMap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMap::~Graphic3d_CubeMap()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
@@ -26,24 +26,12 @@ class Graphic3d_CubeMap : public Graphic3d_TextureMap
|
||||
public:
|
||||
|
||||
//! Constructor defining loading cubemap from file.
|
||||
Graphic3d_CubeMap (const TCollection_AsciiString& theFileName,
|
||||
Standard_Boolean theToGenerateMipmaps = Standard_False) :
|
||||
Graphic3d_TextureMap (theFileName, Graphic3d_TOT_CUBEMAP),
|
||||
myCurrentSide (Graphic3d_CMS_POS_X),
|
||||
myEndIsReached (false),
|
||||
myZIsInverted (false),
|
||||
myHasMipmaps (theToGenerateMipmaps)
|
||||
{}
|
||||
Standard_EXPORT Graphic3d_CubeMap (const TCollection_AsciiString& theFileName,
|
||||
Standard_Boolean theToGenerateMipmaps = Standard_False);
|
||||
|
||||
//! Constructor defining direct cubemap initialization from PixMap.
|
||||
Graphic3d_CubeMap (const Handle(Image_PixMap)& thePixmap = Handle(Image_PixMap)(),
|
||||
Standard_Boolean theToGenerateMipmaps = Standard_False) :
|
||||
Graphic3d_TextureMap (thePixmap, Graphic3d_TOT_CUBEMAP),
|
||||
myCurrentSide (Graphic3d_CMS_POS_X),
|
||||
myEndIsReached (false),
|
||||
myZIsInverted (false),
|
||||
myHasMipmaps (theToGenerateMipmaps)
|
||||
{}
|
||||
Standard_EXPORT Graphic3d_CubeMap (const Handle(Image_PixMap)& thePixmap = Handle(Image_PixMap)(),
|
||||
Standard_Boolean theToGenerateMipmaps = Standard_False);
|
||||
|
||||
//! Returns whether the iterator has reached the end (true if it hasn't).
|
||||
Standard_Boolean More() const { return !myEndIsReached; }
|
||||
@@ -100,14 +88,13 @@ public:
|
||||
}
|
||||
|
||||
//! Empty destructor.
|
||||
~Graphic3d_CubeMap() {}
|
||||
Standard_EXPORT virtual ~Graphic3d_CubeMap();
|
||||
|
||||
protected:
|
||||
|
||||
Graphic3d_CubeMapSide myCurrentSide; //!< Iterator state
|
||||
Standard_Boolean myEndIsReached; //!< Indicates whether end of iteration has been reached or hasn't
|
||||
Standard_Boolean myZIsInverted; //!< Indicates whether Z axis is inverted that allows to synchronize vertical flip of cubemap
|
||||
Standard_Boolean myHasMipmaps; //!< Indicates whether mipmaps of cubemap will be generated or not
|
||||
|
||||
};
|
||||
|
||||
|
@@ -42,7 +42,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_MediaTexture, Graphic3d_Texture2D)
|
||||
// ================================================================
|
||||
Graphic3d_MediaTexture::Graphic3d_MediaTexture (const Handle(Standard_HMutex)& theMutex,
|
||||
Standard_Integer thePlane)
|
||||
: Graphic3d_Texture2D ("", Graphic3d_TOT_2D),
|
||||
: Graphic3d_Texture2D ("", Graphic3d_TypeOfTexture_2D),
|
||||
myMutex (theMutex),
|
||||
myPlane (thePlane)
|
||||
{
|
||||
|
@@ -14,10 +14,8 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <Graphic3d_Texture1Dmanual.hxx>
|
||||
#include <Graphic3d_TypeOfTextureMode.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture1Dmanual,Graphic3d_Texture1D)
|
||||
@@ -27,7 +25,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture1Dmanual,Graphic3d_Texture1D)
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1Dmanual::Graphic3d_Texture1Dmanual (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_Texture1D (theFileName, Graphic3d_TOT_1D)
|
||||
: Graphic3d_Texture1D (theFileName, Graphic3d_TypeOfTexture_1D)
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -37,7 +35,7 @@ Graphic3d_Texture1Dmanual::Graphic3d_Texture1Dmanual (const TCollection_AsciiStr
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1Dmanual::Graphic3d_Texture1Dmanual (const Graphic3d_NameOfTexture1D theNOT)
|
||||
: Graphic3d_Texture1D (theNOT, Graphic3d_TOT_1D)
|
||||
: Graphic3d_Texture1D (theNOT, Graphic3d_TypeOfTexture_1D)
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -47,7 +45,7 @@ Graphic3d_Texture1Dmanual::Graphic3d_Texture1Dmanual (const Graphic3d_NameOfText
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1Dmanual::Graphic3d_Texture1Dmanual (const Handle(Image_PixMap)& thePixMap)
|
||||
: Graphic3d_Texture1D (thePixMap, Graphic3d_TOT_1D)
|
||||
: Graphic3d_Texture1D (thePixMap, Graphic3d_TypeOfTexture_1D)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
@@ -17,55 +17,27 @@
|
||||
#ifndef _Graphic3d_Texture1Dmanual_HeaderFile
|
||||
#define _Graphic3d_Texture1Dmanual_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <Graphic3d_Texture1D.hxx>
|
||||
#include <Graphic3d_NameOfTexture1D.hxx>
|
||||
class TCollection_AsciiString;
|
||||
|
||||
|
||||
class Graphic3d_Texture1Dmanual;
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_Texture1Dmanual, Graphic3d_Texture1D)
|
||||
|
||||
//! This class provides the implementation of a manual 1D texture.
|
||||
//! you MUST provides texture coordinates on your facets if you want to see your texture.
|
||||
//! you MUST provide texture coordinates on your facets if you want to see your texture.
|
||||
class Graphic3d_Texture1Dmanual : public Graphic3d_Texture1D
|
||||
{
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_Texture1Dmanual, Graphic3d_Texture1D)
|
||||
public:
|
||||
|
||||
|
||||
//! Creates a texture from the file FileName.
|
||||
Standard_EXPORT Graphic3d_Texture1Dmanual(const TCollection_AsciiString& theFileName);
|
||||
|
||||
|
||||
//! Create a texture from a predefined texture name set.
|
||||
Standard_EXPORT Graphic3d_Texture1Dmanual(const Graphic3d_NameOfTexture1D theNOT);
|
||||
|
||||
|
||||
//! Creates a texture from the pixmap.
|
||||
Standard_EXPORT Graphic3d_Texture1Dmanual(const Handle(Image_PixMap)& thePixMap);
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_Texture1Dmanual,Graphic3d_Texture1D)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _Graphic3d_Texture1Dmanual_HeaderFile
|
||||
|
@@ -28,7 +28,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture1Dsegment,Graphic3d_Texture1D)
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_Texture1D (theFileName, Graphic3d_TOT_1D),
|
||||
: Graphic3d_Texture1D (theFileName, Graphic3d_TypeOfTexture_1D),
|
||||
myX1 (0.0f),
|
||||
myY1 (0.0f),
|
||||
myZ1 (0.0f),
|
||||
@@ -47,7 +47,7 @@ Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment (const TCollection_AsciiS
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment (const Graphic3d_NameOfTexture1D theNOT)
|
||||
: Graphic3d_Texture1D (theNOT, Graphic3d_TOT_1D),
|
||||
: Graphic3d_Texture1D (theNOT, Graphic3d_TypeOfTexture_1D),
|
||||
myX1 (0.0f),
|
||||
myY1 (0.0f),
|
||||
myZ1 (0.0f),
|
||||
@@ -66,7 +66,7 @@ Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment (const Graphic3d_NameOfTe
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment (const Handle(Image_PixMap)& thePixMap)
|
||||
: Graphic3d_Texture1D (thePixMap, Graphic3d_TOT_1D),
|
||||
: Graphic3d_Texture1D (thePixMap, Graphic3d_TypeOfTexture_1D),
|
||||
myX1 (0.0f),
|
||||
myY1 (0.0f),
|
||||
myZ1 (0.0f),
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <Graphic3d_Texture2D.hxx>
|
||||
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture2D,Graphic3d_TextureMap)
|
||||
@@ -46,6 +47,20 @@ static const char *NameOfTexture2d_to_FileName[] =
|
||||
"2d_chess.rgba"
|
||||
};
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2D::Graphic3d_Texture2D (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_TextureMap (theFileName, Graphic3d_TypeOfTexture_2D),
|
||||
myName (Graphic3d_NOT_2D_UNKNOWN)
|
||||
{
|
||||
myHasMipmaps = true;
|
||||
myParams->SetModulate (true);
|
||||
myParams->SetRepeat (true);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2D
|
||||
// purpose :
|
||||
@@ -55,6 +70,25 @@ Graphic3d_Texture2D::Graphic3d_Texture2D (const TCollection_AsciiString& theFile
|
||||
: Graphic3d_TextureMap (theFileName, theType),
|
||||
myName (Graphic3d_NOT_2D_UNKNOWN)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2D::Graphic3d_Texture2D (const Graphic3d_NameOfTexture2D theNOT)
|
||||
: Graphic3d_TextureMap (NameOfTexture2d_to_FileName[theNOT], Graphic3d_TypeOfTexture_2D),
|
||||
myName (theNOT)
|
||||
{
|
||||
myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
|
||||
myTexId = TCollection_AsciiString ("Graphic3d_Texture2D_")
|
||||
+ NameOfTexture2d_to_FileName[theNOT];
|
||||
|
||||
myHasMipmaps = true;
|
||||
myParams->SetModulate (true);
|
||||
myParams->SetRepeat (true);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -71,6 +105,20 @@ Graphic3d_Texture2D::Graphic3d_Texture2D (const Graphic3d_NameOfTexture2D theNOT
|
||||
+ NameOfTexture2d_to_FileName[theNOT];
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2D::Graphic3d_Texture2D (const Handle(Image_PixMap)& thePixMap)
|
||||
: Graphic3d_TextureMap (thePixMap, Graphic3d_TypeOfTexture_2D),
|
||||
myName (Graphic3d_NOT_2D_UNKNOWN)
|
||||
{
|
||||
myHasMipmaps = true;
|
||||
myParams->SetModulate (true);
|
||||
myParams->SetRepeat (true);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2D
|
||||
// purpose :
|
||||
@@ -80,6 +128,7 @@ Graphic3d_Texture2D::Graphic3d_Texture2D (const Handle(Image_PixMap)& thePixM
|
||||
: Graphic3d_TextureMap (thePixMap, theType),
|
||||
myName (Graphic3d_NOT_2D_UNKNOWN)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -34,6 +34,18 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
//! Creates a texture from a file.
|
||||
//! MipMaps levels will be automatically generated if needed.
|
||||
Standard_EXPORT Graphic3d_Texture2D (const TCollection_AsciiString& theFileName);
|
||||
|
||||
//! Creates a texture from a predefined texture name set.
|
||||
//! MipMaps levels will be automatically generated if needed.
|
||||
Standard_EXPORT Graphic3d_Texture2D (const Graphic3d_NameOfTexture2D theNOT);
|
||||
|
||||
//! Creates a texture from the pixmap.
|
||||
//! MipMaps levels will be automatically generated if needed.
|
||||
Standard_EXPORT Graphic3d_Texture2D (const Handle(Image_PixMap)& thePixMap);
|
||||
|
||||
//! Returns the name of the predefined textures or NOT_2D_UNKNOWN
|
||||
//! when the name is given as a filename.
|
||||
Standard_EXPORT Graphic3d_NameOfTexture2D Name() const;
|
||||
@@ -42,13 +54,6 @@ public:
|
||||
//! Note that this method does not invalidate already uploaded resources - consider calling ::UpdateRevision() if needed.
|
||||
Standard_EXPORT void SetImage (const Handle(Image_PixMap)& thePixMap);
|
||||
|
||||
//! Return true if mip-maps should be used.
|
||||
Standard_Boolean HasMipMaps() const { return myType == Graphic3d_TOT_2D_MIPMAP; }
|
||||
|
||||
//! Set if mip-maps should be used (generated if needed).
|
||||
//! Note that this method should be called before loading / using the texture.
|
||||
void SetMipMaps (const Standard_Boolean theToUse) { myType = theToUse ? Graphic3d_TOT_2D_MIPMAP : Graphic3d_TOT_2D; }
|
||||
|
||||
protected:
|
||||
|
||||
Standard_EXPORT Graphic3d_Texture2D(const TCollection_AsciiString& theFileName, const Graphic3d_TypeOfTexture theType);
|
||||
|
@@ -1,58 +0,0 @@
|
||||
// Created on: 1997-07-28
|
||||
// Created by: Pierre CHALAMET
|
||||
// Copyright (c) 1997-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
#include <Graphic3d_TypeOfTextureMode.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture2Dmanual,Graphic3d_Texture2D)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2Dmanual
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2Dmanual::Graphic3d_Texture2Dmanual (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_Texture2D (theFileName, Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2Dmanual
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2Dmanual::Graphic3d_Texture2Dmanual (const Graphic3d_NameOfTexture2D theNOT)
|
||||
: Graphic3d_Texture2D (theNOT, Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture2Dmanual
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2Dmanual::Graphic3d_Texture2Dmanual (const Handle(Image_PixMap)& thePixMap)
|
||||
: Graphic3d_Texture2D (thePixMap, Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
@@ -20,28 +20,7 @@
|
||||
#include <Graphic3d_Texture2D.hxx>
|
||||
#include <Graphic3d_NameOfTexture2D.hxx>
|
||||
|
||||
//! This class defined a manual texture 2D
|
||||
//! facets MUST define texture coordinate
|
||||
//! if you want to see somethings on.
|
||||
class Graphic3d_Texture2Dmanual : public Graphic3d_Texture2D
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_Texture2Dmanual,Graphic3d_Texture2D)
|
||||
public:
|
||||
|
||||
//! Creates a texture from a file.
|
||||
//! MipMaps levels will be automatically generated if needed.
|
||||
Standard_EXPORT Graphic3d_Texture2Dmanual(const TCollection_AsciiString& theFileName);
|
||||
|
||||
//! Creates a texture from a predefined texture name set.
|
||||
//! MipMaps levels will be automatically generated if needed.
|
||||
Standard_EXPORT Graphic3d_Texture2Dmanual(const Graphic3d_NameOfTexture2D theNOT);
|
||||
|
||||
//! Creates a texture from the pixmap.
|
||||
//! MipMaps levels will be automatically generated if needed.
|
||||
Standard_EXPORT Graphic3d_Texture2Dmanual(const Handle(Image_PixMap)& thePixMap);
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_Texture2Dmanual, Graphic3d_Texture2D)
|
||||
Standard_DEPRECATED ("Deprecated alias to Graphic3d_Texture2D")
|
||||
typedef Graphic3d_Texture2D Graphic3d_Texture2Dmanual;
|
||||
|
||||
#endif // _Graphic3d_Texture2Dmanual_HeaderFile
|
||||
|
@@ -28,11 +28,8 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture2Dplane,Graphic3d_Texture2D)
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_Texture2D (theFileName, Graphic3d_TOT_2D_MIPMAP)
|
||||
: Graphic3d_Texture2D (theFileName)
|
||||
{
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
|
||||
@@ -43,11 +40,8 @@ Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const TCollection_AsciiStrin
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Graphic3d_NameOfTexture2D theNOT)
|
||||
: Graphic3d_Texture2D (theNOT, Graphic3d_TOT_2D_MIPMAP)
|
||||
: Graphic3d_Texture2D (theNOT)
|
||||
{
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
|
||||
@@ -58,11 +52,8 @@ Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Graphic3d_NameOfTextur
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Handle(Image_PixMap)& thePixMap)
|
||||
: Graphic3d_Texture2D (thePixMap, Graphic3d_TOT_2D_MIPMAP)
|
||||
: Graphic3d_Texture2D (thePixMap)
|
||||
{
|
||||
myParams->SetModulate (Standard_True);
|
||||
myParams->SetRepeat (Standard_True);
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
|
||||
Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
|
||||
|
127
src/Graphic3d/Graphic3d_Texture3D.cxx
Normal file
127
src/Graphic3d/Graphic3d_Texture3D.cxx
Normal file
@@ -0,0 +1,127 @@
|
||||
// Copyright (c) 2022 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 <Graphic3d_Texture3D.hxx>
|
||||
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
#include <Message.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture3D, Graphic3d_TextureMap)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture3D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture3D::Graphic3d_Texture3D (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_TextureMap (theFileName, Graphic3d_TypeOfTexture_3D)
|
||||
{
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture3D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture3D::Graphic3d_Texture3D (const Handle(Image_PixMap)& thePixMap)
|
||||
: Graphic3d_TextureMap (thePixMap, Graphic3d_TypeOfTexture_3D)
|
||||
{
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Texture3D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture3D::Graphic3d_Texture3D (const NCollection_Array1<TCollection_AsciiString>& theFiles)
|
||||
: Graphic3d_TextureMap ("", Graphic3d_TypeOfTexture_3D)
|
||||
{
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
myPaths.Resize (theFiles.Lower(), theFiles.Upper(), false);
|
||||
myPaths.Assign (theFiles);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ~Graphic3d_Texture3D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Texture3D::~Graphic3d_Texture3D()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetImage
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Texture3D::SetImage (const Handle(Image_PixMap)& thePixMap)
|
||||
{
|
||||
myPixMap = thePixMap;
|
||||
myPath = OSD_Path();
|
||||
|
||||
NCollection_Array1<TCollection_AsciiString> anArr;
|
||||
myPaths.Move (anArr);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetImage
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Image_PixMap) Graphic3d_Texture3D::GetImage (const Handle(Image_SupportedFormats)& theSupported)
|
||||
{
|
||||
if (myPaths.IsEmpty()
|
||||
|| !myPixMap.IsNull())
|
||||
{
|
||||
return base_type::GetImage (theSupported);
|
||||
}
|
||||
|
||||
Handle(Image_PixMap) anImage3D;
|
||||
const Standard_Integer aNbSlices = myPaths.Length();
|
||||
for (Standard_Integer aSlice = 0; aSlice < aNbSlices; ++aSlice)
|
||||
{
|
||||
const TCollection_AsciiString& aSlicePath = myPaths[myPaths.Lower() + aSlice];
|
||||
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
|
||||
if (!anImage->Load (aSlicePath))
|
||||
{
|
||||
Message::SendFail() << "Graphic3d_Texture3D::GetImage() failed to load slice " << aSlice << " from '" << aSlicePath << "'";
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
|
||||
convertToCompatible (theSupported, anImage);
|
||||
if (anImage3D.IsNull())
|
||||
{
|
||||
myIsTopDown = anImage->IsTopDown();
|
||||
anImage3D = new Image_PixMap();
|
||||
anImage3D->SetTopDown (myIsTopDown);
|
||||
if (!anImage3D->InitTrash3D (anImage->Format(),
|
||||
NCollection_Vec3<Standard_Size> (anImage->SizeX(), anImage->SizeY(), aNbSlices),
|
||||
anImage->SizeRowBytes()))
|
||||
{
|
||||
Message::SendFail() << "Graphic3d_Texture3D::GetImage() failed to allocate 3D image " << (int )anImage->SizeX() << "x" << (int )anImage->SizeY() << "x" << aNbSlices;
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
}
|
||||
if (anImage->Format() != anImage3D->Format()
|
||||
|| anImage->SizeX() != anImage3D->SizeX()
|
||||
|| anImage->SizeY() != anImage3D->SizeY()
|
||||
|| anImage->SizeRowBytes() != anImage3D->SizeRowBytes())
|
||||
{
|
||||
Message::SendFail() << "Graphic3d_Texture3D::GetImage() slice " << aSlice << " from '" << aSlicePath << "' have different dimensions";
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
|
||||
memcpy (anImage3D->ChangeSlice (aSlice), anImage->Data(), anImage->SizeBytes());
|
||||
}
|
||||
|
||||
return anImage3D;
|
||||
}
|
51
src/Graphic3d/Graphic3d_Texture3D.hxx
Normal file
51
src/Graphic3d/Graphic3d_Texture3D.hxx
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) 2022 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 _Graphic3d_Texture3D_HeaderFile
|
||||
#define _Graphic3d_Texture3D_HeaderFile
|
||||
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
|
||||
//! This abstract class for managing 3D textures.
|
||||
class Graphic3d_Texture3D : public Graphic3d_TextureMap
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_Texture3D, Graphic3d_TextureMap)
|
||||
public:
|
||||
|
||||
//! Creates a texture from a file.
|
||||
Standard_EXPORT Graphic3d_Texture3D (const TCollection_AsciiString& theFileName);
|
||||
|
||||
//! Creates a texture from the pixmap.
|
||||
Standard_EXPORT Graphic3d_Texture3D (const Handle(Image_PixMap)& thePixMap);
|
||||
|
||||
//! Creates a texture from a file.
|
||||
Standard_EXPORT Graphic3d_Texture3D (const NCollection_Array1<TCollection_AsciiString>& theFiles);
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT virtual ~Graphic3d_Texture3D();
|
||||
|
||||
//! Assign new image to the texture.
|
||||
//! Note that this method does not invalidate already uploaded resources - consider calling ::UpdateRevision() if needed.
|
||||
Standard_EXPORT void SetImage (const Handle(Image_PixMap)& thePixMap);
|
||||
|
||||
//! Load and return image.
|
||||
Standard_EXPORT virtual Handle(Image_PixMap) GetImage (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
NCollection_Array1<TCollection_AsciiString> myPaths;
|
||||
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_Texture3D_HeaderFile
|
@@ -42,9 +42,10 @@ static const char *NameOfTextureEnv_to_FileName[] =
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_TextureEnv::Graphic3d_TextureEnv (const TCollection_AsciiString& theFileName)
|
||||
: Graphic3d_TextureRoot (theFileName, Graphic3d_TOT_2D_MIPMAP),
|
||||
: Graphic3d_TextureRoot (theFileName, Graphic3d_TypeOfTexture_2D),
|
||||
myName (Graphic3d_NOT_ENV_UNKNOWN)
|
||||
{
|
||||
myHasMipmaps = true;
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_SPHERE,
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
|
||||
@@ -56,9 +57,10 @@ Graphic3d_TextureEnv::Graphic3d_TextureEnv (const TCollection_AsciiString& theFi
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_TextureEnv::Graphic3d_TextureEnv (const Graphic3d_NameOfTextureEnv theNOT)
|
||||
: Graphic3d_TextureRoot (NameOfTextureEnv_to_FileName[theNOT], Graphic3d_TOT_2D_MIPMAP),
|
||||
: Graphic3d_TextureRoot (NameOfTextureEnv_to_FileName[theNOT], Graphic3d_TypeOfTexture_2D),
|
||||
myName (theNOT)
|
||||
{
|
||||
myHasMipmaps = true;
|
||||
myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
|
||||
myTexId = TCollection_AsciiString ("Graphic3d_TextureEnv_")
|
||||
+ NameOfTextureEnv_to_FileName[theNOT];
|
||||
@@ -74,9 +76,10 @@ Graphic3d_TextureEnv::Graphic3d_TextureEnv (const Graphic3d_NameOfTextureEnv the
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_TextureEnv::Graphic3d_TextureEnv (const Handle(Image_PixMap)& thePixMap)
|
||||
: Graphic3d_TextureRoot (thePixMap, Graphic3d_TOT_2D_MIPMAP),
|
||||
: Graphic3d_TextureRoot (thePixMap, Graphic3d_TypeOfTexture_2D),
|
||||
myName (Graphic3d_NOT_ENV_UNKNOWN)
|
||||
{
|
||||
myHasMipmaps = true;
|
||||
myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
|
||||
myParams->SetGenMode (Graphic3d_TOTM_SPHERE,
|
||||
Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
|
||||
|
@@ -92,9 +92,10 @@ Graphic3d_TextureRoot::Graphic3d_TextureRoot (const TCollection_AsciiString& the
|
||||
: myParams (new Graphic3d_TextureParams()),
|
||||
myPath (theFileName),
|
||||
myRevision (0),
|
||||
myType (theType),
|
||||
myType (theType == Graphic3d_TOT_2D_MIPMAP ? Graphic3d_TypeOfTexture_2D : theType),
|
||||
myIsColorMap (true),
|
||||
myIsTopDown (true)
|
||||
myIsTopDown (true),
|
||||
myHasMipmaps (theType == Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
generateId();
|
||||
}
|
||||
@@ -108,9 +109,10 @@ Graphic3d_TextureRoot::Graphic3d_TextureRoot (const Handle(Image_PixMap)& theP
|
||||
: myParams (new Graphic3d_TextureParams()),
|
||||
myPixMap (thePixMap),
|
||||
myRevision (0),
|
||||
myType (theType),
|
||||
myType (theType == Graphic3d_TOT_2D_MIPMAP ? Graphic3d_TypeOfTexture_2D : theType),
|
||||
myIsColorMap (true),
|
||||
myIsTopDown (true)
|
||||
myIsTopDown (true),
|
||||
myHasMipmaps (theType == Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
generateId();
|
||||
}
|
||||
@@ -214,9 +216,9 @@ Handle(Image_PixMap) Graphic3d_TextureRoot::GetImage (const Handle(Image_Support
|
||||
void Graphic3d_TextureRoot::convertToCompatible (const Handle(Image_SupportedFormats)& theSupported,
|
||||
const Handle(Image_PixMap)& theImage)
|
||||
{
|
||||
if (theSupported.IsNull()
|
||||
|| theSupported->IsSupported (theImage->Format())
|
||||
|| theImage.IsNull())
|
||||
if (theImage.IsNull()
|
||||
|| theSupported.IsNull()
|
||||
|| theSupported->IsSupported (theImage->Format()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -113,6 +113,12 @@ public:
|
||||
//! Set flag indicating color nature of values within the texture.
|
||||
void SetColorMap (Standard_Boolean theIsColor) { myIsColorMap = theIsColor; }
|
||||
|
||||
//! Returns whether mipmaps should be generated or not.
|
||||
Standard_Boolean HasMipmaps() const { return myHasMipmaps; }
|
||||
|
||||
//! Sets whether to generate mipmaps or not.
|
||||
void SetMipmapsGeneration (Standard_Boolean theToGenerateMipmaps) { myHasMipmaps = theToGenerateMipmaps; }
|
||||
|
||||
//! Returns whether row's memory layout is top-down.
|
||||
Standard_Boolean IsTopDown() const { return myIsTopDown; }
|
||||
|
||||
@@ -148,7 +154,7 @@ protected:
|
||||
Graphic3d_TypeOfTexture myType; //!< texture type
|
||||
Standard_Boolean myIsColorMap; //!< flag indicating color nature of values within the texture
|
||||
Standard_Boolean myIsTopDown; //!< Stores rows's memory layout
|
||||
|
||||
Standard_Boolean myHasMipmaps; //!< Indicates whether mipmaps should be generated or not
|
||||
|
||||
};
|
||||
|
||||
|
@@ -20,10 +20,26 @@
|
||||
//! Type of the texture file format.
|
||||
enum Graphic3d_TypeOfTexture
|
||||
{
|
||||
Graphic3d_TOT_1D,
|
||||
Graphic3d_TOT_2D,
|
||||
Graphic3d_TOT_2D_MIPMAP,
|
||||
Graphic3d_TOT_CUBEMAP
|
||||
//! 1D texture (array).
|
||||
//! Note that this texture type might be unsupported by graphics API (emulated by 2D texture with 1 pixel height).
|
||||
Graphic3d_TypeOfTexture_1D,
|
||||
|
||||
//! 2D texture (image plane).
|
||||
Graphic3d_TypeOfTexture_2D,
|
||||
|
||||
//! 3D texture (a set of image planes).
|
||||
Graphic3d_TypeOfTexture_3D,
|
||||
|
||||
//! Cubemap texture (6 image planes defining cube sides).
|
||||
Graphic3d_TypeOfTexture_CUBEMAP,
|
||||
|
||||
//! Obsolete type - Graphic3d_TextureRoot::SetMipmapsGeneration() should be used instead.
|
||||
Graphic3d_TOT_2D_MIPMAP,
|
||||
|
||||
// old aliases
|
||||
Graphic3d_TOT_1D = Graphic3d_TypeOfTexture_1D,
|
||||
Graphic3d_TOT_2D = Graphic3d_TypeOfTexture_2D,
|
||||
Graphic3d_TOT_CUBEMAP = Graphic3d_TypeOfTexture_CUBEMAP
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_TypeOfTexture_HeaderFile
|
||||
|
@@ -254,7 +254,7 @@ Standard_Boolean IGESControl_Writer::Write
|
||||
(const Standard_CString file, const Standard_Boolean fnes)
|
||||
{
|
||||
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
|
||||
std::shared_ptr<std::ostream> aStream = aFileSystem->OpenOStream (file, std::ios::out);
|
||||
std::shared_ptr<std::ostream> aStream = aFileSystem->OpenOStream (file, std::ios::out | std::ios::binary);
|
||||
if (aStream.get() == NULL)
|
||||
{
|
||||
return Standard_False;
|
||||
|
@@ -102,7 +102,7 @@ static Handle(IGESData_FileProtocol) IGESProto;
|
||||
|
||||
if (igesmod.IsNull() || prot.IsNull()) return Standard_False;
|
||||
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
|
||||
std::shared_ptr<std::ostream> aStream = aFileSystem->OpenOStream (ctx.FileName(), std::ios::out);
|
||||
std::shared_ptr<std::ostream> aStream = aFileSystem->OpenOStream (ctx.FileName(), std::ios::out | std::ios::binary);
|
||||
if (aStream.get() == NULL)
|
||||
{
|
||||
ctx.CCheck(0)->AddFail("IGES File could not be created");
|
||||
|
@@ -66,6 +66,8 @@ namespace
|
||||
case FIT_RGBF: return Image_Format_RGBF;
|
||||
case FIT_RGBAF: return Image_Format_RGBAF;
|
||||
case FIT_FLOAT: return Image_Format_GrayF;
|
||||
case FIT_INT16:
|
||||
case FIT_UINT16: return Image_Format_Gray16;
|
||||
case FIT_BITMAP:
|
||||
{
|
||||
switch (theColorTypeFI)
|
||||
@@ -118,6 +120,8 @@ namespace
|
||||
case Image_Format_Gray:
|
||||
case Image_Format_Alpha:
|
||||
return FIT_BITMAP;
|
||||
case Image_Format_Gray16:
|
||||
return FIT_UINT16;
|
||||
default:
|
||||
return FIT_UNKNOWN;
|
||||
}
|
||||
@@ -304,6 +308,10 @@ namespace
|
||||
{
|
||||
return Image_Format_Gray;
|
||||
}
|
||||
else if (theFormat == GUID_WICPixelFormat16bppGray)
|
||||
{
|
||||
return Image_Format_Gray16;
|
||||
}
|
||||
return Image_Format_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -318,6 +326,7 @@ namespace
|
||||
case Image_Format_BGR: return GUID_WICPixelFormat24bppBGR;
|
||||
case Image_Format_Gray: return GUID_WICPixelFormat8bppGray;
|
||||
case Image_Format_Alpha: return GUID_WICPixelFormat8bppGray; // GUID_WICPixelFormat8bppAlpha
|
||||
case Image_Format_Gray16: return GUID_WICPixelFormat16bppGray;
|
||||
case Image_Format_GrayF: // GUID_WICPixelFormat32bppGrayFloat
|
||||
case Image_Format_AlphaF:
|
||||
case Image_Format_RGBAF: // GUID_WICPixelFormat128bppRGBAFloat
|
||||
@@ -1081,7 +1090,8 @@ bool Image_AlienPixMap::Save (const TCollection_AsciiString& theFileName)
|
||||
{
|
||||
aFileFormat = GUID_ContainerFormatJpeg;
|
||||
}
|
||||
else if (aFileNameLower.EndsWith (".tiff"))
|
||||
else if (aFileNameLower.EndsWith (".tiff")
|
||||
|| aFileNameLower.EndsWith (".tif"))
|
||||
{
|
||||
aFileFormat = GUID_ContainerFormatTiff;
|
||||
}
|
||||
|
@@ -33,9 +33,11 @@ enum Image_Format
|
||||
Image_Format_BGRF, //!< same as RGBF but with different components order
|
||||
Image_Format_RGBAF, //!< 4 floats (16-bytes) RGBA image plane
|
||||
Image_Format_BGRAF, //!< same as RGBAF but with different components order
|
||||
Image_Format_RGF_half, //!< 2 half-floats (4-bytes) RG image plane
|
||||
Image_Format_GrayF_half, //!< 1 half-float (2-bytes) intensity of color
|
||||
Image_Format_RGF_half, //!< 2 half-floats (4-bytes) RG image plane
|
||||
Image_Format_RGBAF_half, //!< 4 half-floats (8-bytes) RGBA image plane
|
||||
Image_Format_Gray16, //!< 2 bytes per pixel (unsigned short integer), intensity of the color
|
||||
};
|
||||
enum { Image_Format_NB = Image_Format_RGBAF_half + 1 };
|
||||
enum { Image_Format_NB = Image_Format_Gray16 + 1 };
|
||||
|
||||
#endif // _Image_Format_HeaderFile
|
||||
|
@@ -62,8 +62,10 @@ namespace
|
||||
ImageFormatInfo(BGRF, 3, sizeof(float) * 3),
|
||||
ImageFormatInfo(RGBAF, 4, sizeof(float) * 4),
|
||||
ImageFormatInfo(BGRAF, 4, sizeof(float) * 4),
|
||||
ImageFormatInfo(GrayF_half, 1, sizeof(uint16_t) * 1),
|
||||
ImageFormatInfo(RGF_half, 2, sizeof(uint16_t) * 2),
|
||||
ImageFormatInfo(RGBAF_half, 4, sizeof(uint16_t) * 4),
|
||||
ImageFormatInfo(Gray16, 1, 2),
|
||||
CompressedImageFormatInfo(RGB_S3TC_DXT1, 3, 1), // DXT1 uses circa half a byte per pixel (64 bits per 4x4 block)
|
||||
CompressedImageFormatInfo(RGBA_S3TC_DXT1, 4, 1),
|
||||
CompressedImageFormatInfo(RGBA_S3TC_DXT3, 4, 1), // DXT3/5 uses circa 1 byte per pixel (128 bits per 4x4 block)
|
||||
@@ -71,7 +73,8 @@ namespace
|
||||
};
|
||||
}
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Image_PixMap,Standard_Transient)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Image_PixMapData, NCollection_Buffer)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Image_PixMap, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : DefaultAllocator
|
||||
@@ -150,6 +153,31 @@ void Image_PixMap::SetFormat (Image_Format thePixelFormat)
|
||||
myImgFormat = thePixelFormat;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitWrapper3D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Image_PixMap::InitWrapper3D (Image_Format thePixelFormat,
|
||||
Standard_Byte* theDataPtr,
|
||||
const NCollection_Vec3<Standard_Size>& theSizeXYZ,
|
||||
const Standard_Size theSizeRowBytes)
|
||||
{
|
||||
Clear();
|
||||
myImgFormat = thePixelFormat;
|
||||
if (theSizeXYZ.x() == 0
|
||||
|| theSizeXYZ.y() == 0
|
||||
|| theSizeXYZ.z() == 0
|
||||
|| theDataPtr == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Handle(NCollection_BaseAllocator) anEmptyAlloc;
|
||||
myData.Init (anEmptyAlloc, Image_PixMap::SizePixelBytes (thePixelFormat),
|
||||
theSizeXYZ, theSizeRowBytes, theDataPtr);
|
||||
return true;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitWrapper
|
||||
// purpose :
|
||||
@@ -159,18 +187,32 @@ bool Image_PixMap::InitWrapper (Image_Format thePixelFormat,
|
||||
const Standard_Size theSizeX,
|
||||
const Standard_Size theSizeY,
|
||||
const Standard_Size theSizeRowBytes)
|
||||
{
|
||||
return InitWrapper3D (thePixelFormat, theDataPtr, NCollection_Vec3<Standard_Size> (theSizeX, theSizeY, 1), theSizeRowBytes);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitTrash3D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Image_PixMap::InitTrash3D (Image_Format thePixelFormat,
|
||||
const NCollection_Vec3<Standard_Size>& theSizeXYZ,
|
||||
const Standard_Size theSizeRowBytes)
|
||||
{
|
||||
Clear();
|
||||
myImgFormat = thePixelFormat;
|
||||
if ((theSizeX == 0) || (theSizeY == 0) || (theDataPtr == NULL))
|
||||
if (theSizeXYZ.x() == 0
|
||||
|| theSizeXYZ.y() == 0
|
||||
|| theSizeXYZ.z() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Handle(NCollection_BaseAllocator) anEmptyAlloc;
|
||||
myData.Init (anEmptyAlloc, Image_PixMap::SizePixelBytes (thePixelFormat),
|
||||
theSizeX, theSizeY, theSizeRowBytes, theDataPtr);
|
||||
return true;
|
||||
// use argument only if it greater
|
||||
const Standard_Size aSizeRowBytes = std::max (theSizeRowBytes, theSizeXYZ.x() * SizePixelBytes (thePixelFormat));
|
||||
myData.Init (DefaultAllocator(), Image_PixMap::SizePixelBytes (thePixelFormat),
|
||||
theSizeXYZ, aSizeRowBytes, NULL);
|
||||
return !myData.IsEmpty();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -182,33 +224,31 @@ bool Image_PixMap::InitTrash (Image_Format thePixelFormat,
|
||||
const Standard_Size theSizeY,
|
||||
const Standard_Size theSizeRowBytes)
|
||||
{
|
||||
Clear();
|
||||
myImgFormat = thePixelFormat;
|
||||
if ((theSizeX == 0) || (theSizeY == 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// use argument only if it greater
|
||||
const Standard_Size aSizeRowBytes = std::max (theSizeRowBytes, theSizeX * SizePixelBytes (thePixelFormat));
|
||||
myData.Init (DefaultAllocator(), Image_PixMap::SizePixelBytes (thePixelFormat),
|
||||
theSizeX, theSizeY, aSizeRowBytes, NULL);
|
||||
return !myData.IsEmpty();
|
||||
return InitTrash3D (thePixelFormat, NCollection_Vec3<Standard_Size> (theSizeX, theSizeY, 1), theSizeRowBytes);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitZero
|
||||
// function : InitZero3D
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Image_PixMap::InitZero (Image_Format thePixelFormat,
|
||||
const Standard_Size theSizeX,
|
||||
const Standard_Size theSizeY,
|
||||
const Standard_Size theSizeRowBytes,
|
||||
const Standard_Byte theValue)
|
||||
bool Image_PixMap::InitZero3D (Image_Format thePixelFormat,
|
||||
const NCollection_Vec3<Standard_Size>& theSizeXYZ,
|
||||
const Standard_Size theSizeRowBytes,
|
||||
const Standard_Byte theValue)
|
||||
{
|
||||
if (!InitTrash (thePixelFormat, theSizeX, theSizeY, theSizeRowBytes))
|
||||
if (theSizeXYZ.z() > 1)
|
||||
{
|
||||
return false;
|
||||
if (!InitTrash3D (thePixelFormat, theSizeXYZ, theSizeRowBytes))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!InitTrash (thePixelFormat, theSizeXYZ.x(), theSizeXYZ.y(), theSizeRowBytes))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
memset (myData.ChangeData(), (int )theValue, SizeBytes());
|
||||
return true;
|
||||
@@ -225,12 +265,24 @@ bool Image_PixMap::InitCopy (const Image_PixMap& theCopy)
|
||||
// self-copying disallowed
|
||||
return false;
|
||||
}
|
||||
if (InitTrash (theCopy.myImgFormat, theCopy.SizeX(), theCopy.SizeY(), theCopy.SizeRowBytes()))
|
||||
|
||||
if (theCopy.SizeZ() > 1)
|
||||
{
|
||||
memcpy (myData.ChangeData(), theCopy.myData.Data(), theCopy.SizeBytes());
|
||||
return true;
|
||||
if (!InitTrash3D (theCopy.myImgFormat, theCopy.SizeXYZ(), theCopy.SizeRowBytes()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
else
|
||||
{
|
||||
if (!InitTrash (theCopy.myImgFormat, theCopy.SizeX(), theCopy.SizeY(), theCopy.SizeRowBytes()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy (myData.ChangeData(), theCopy.myData.Data(), theCopy.SizeBytes());
|
||||
return true;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -241,75 +293,73 @@ void Image_PixMap::Clear()
|
||||
{
|
||||
Handle(NCollection_BaseAllocator) anEmptyAlloc;
|
||||
myData.Init (anEmptyAlloc, Image_PixMap::SizePixelBytes (myImgFormat),
|
||||
0, 0, 0, NULL);
|
||||
NCollection_Vec3<Standard_Size> (0), 0, nullptr);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : PixelColor
|
||||
// function : ColorFromRawPixel
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Quantity_ColorRGBA Image_PixMap::PixelColor (const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Standard_Boolean theToLinearize) const
|
||||
Quantity_ColorRGBA Image_PixMap::ColorFromRawPixel (const Standard_Byte* theRawValue,
|
||||
const Image_Format theFormat,
|
||||
const Standard_Boolean theToLinearize)
|
||||
{
|
||||
if (IsEmpty()
|
||||
|| theX < 0 || (Standard_Size )theX >= SizeX()
|
||||
|| theY < 0 || (Standard_Size )theY >= SizeY())
|
||||
{
|
||||
return Quantity_ColorRGBA (0.0f, 0.0f, 0.0f, 0.0f); // transparent
|
||||
}
|
||||
|
||||
switch (myImgFormat)
|
||||
switch (theFormat)
|
||||
{
|
||||
case Image_Format_GrayF:
|
||||
{
|
||||
const Standard_ShortReal& aPixel = Value<Standard_ShortReal> (theY, theX);
|
||||
const Standard_ShortReal& aPixel = *reinterpret_cast<const Standard_ShortReal*> (theRawValue);
|
||||
return Quantity_ColorRGBA (NCollection_Vec4<float> (aPixel, aPixel, aPixel, 1.0f)); // opaque
|
||||
}
|
||||
case Image_Format_AlphaF:
|
||||
{
|
||||
const Standard_ShortReal& aPixel = Value<Standard_ShortReal> (theY, theX);
|
||||
const Standard_ShortReal& aPixel = *reinterpret_cast<const Standard_ShortReal*> (theRawValue);
|
||||
return Quantity_ColorRGBA (NCollection_Vec4<float> (1.0f, 1.0f, 1.0f, aPixel));
|
||||
}
|
||||
case Image_Format_RGF:
|
||||
{
|
||||
const Image_ColorRGF& aPixel = Value<Image_ColorRGF> (theY, theX);
|
||||
const Image_ColorRGF& aPixel = *reinterpret_cast<const Image_ColorRGF*> (theRawValue);
|
||||
return Quantity_ColorRGBA (NCollection_Vec4<float> (aPixel.r(), aPixel.g(), 0.0f, 1.0f));
|
||||
}
|
||||
case Image_Format_RGBAF:
|
||||
{
|
||||
const Image_ColorRGBAF& aPixel = Value<Image_ColorRGBAF> (theY, theX);
|
||||
const Image_ColorRGBAF& aPixel = *reinterpret_cast<const Image_ColorRGBAF*> (theRawValue);
|
||||
return Quantity_ColorRGBA (NCollection_Vec4<float> (aPixel.r(), aPixel.g(), aPixel.b(), aPixel.a()));
|
||||
}
|
||||
case Image_Format_BGRAF:
|
||||
{
|
||||
const Image_ColorBGRAF& aPixel = Value<Image_ColorBGRAF> (theY, theX);
|
||||
const Image_ColorBGRAF& aPixel = *reinterpret_cast<const Image_ColorBGRAF*> (theRawValue);
|
||||
return Quantity_ColorRGBA (NCollection_Vec4<float> (aPixel.r(), aPixel.g(), aPixel.b(), aPixel.a()));
|
||||
}
|
||||
case Image_Format_RGBF:
|
||||
{
|
||||
const Image_ColorRGBF& aPixel = Value<Image_ColorRGBF> (theY, theX);
|
||||
const Image_ColorRGBF& aPixel = *reinterpret_cast<const Image_ColorRGBF*> (theRawValue);
|
||||
return Quantity_ColorRGBA (NCollection_Vec4<float> (aPixel.r(), aPixel.g(), aPixel.b(), 1.0f)); // opaque
|
||||
}
|
||||
case Image_Format_BGRF:
|
||||
{
|
||||
const Image_ColorBGRF& aPixel = Value<Image_ColorBGRF> (theY, theX);
|
||||
const Image_ColorBGRF& aPixel = *reinterpret_cast<const Image_ColorBGRF*> (theRawValue);
|
||||
return Quantity_ColorRGBA (NCollection_Vec4<float> (aPixel.r(), aPixel.g(), aPixel.b(), 1.0f)); // opaque
|
||||
}
|
||||
case Image_Format_GrayF_half:
|
||||
{
|
||||
const uint16_t& aPixel = *reinterpret_cast<const uint16_t*> (theRawValue);
|
||||
return Quantity_ColorRGBA (NCollection_Vec4<float> (ConvertFromHalfFloat (aPixel), 0.0f, 0.0f, 1.0f));
|
||||
}
|
||||
case Image_Format_RGF_half:
|
||||
{
|
||||
const NCollection_Vec2<uint16_t>& aPixel = Value<NCollection_Vec2<uint16_t>> (theY, theX);
|
||||
const NCollection_Vec2<uint16_t>& aPixel = *reinterpret_cast<const NCollection_Vec2<uint16_t>*> (theRawValue);
|
||||
return Quantity_ColorRGBA (NCollection_Vec4<float> (ConvertFromHalfFloat (aPixel.x()), ConvertFromHalfFloat (aPixel.y()), 0.0f, 1.0f));
|
||||
}
|
||||
case Image_Format_RGBAF_half:
|
||||
{
|
||||
const NCollection_Vec4<uint16_t>& aPixel = Value<NCollection_Vec4<uint16_t>> (theY, theX);
|
||||
const NCollection_Vec4<uint16_t>& aPixel = *reinterpret_cast<const NCollection_Vec4<uint16_t>*> (theRawValue);
|
||||
return Quantity_ColorRGBA (NCollection_Vec4<float> (ConvertFromHalfFloat (aPixel.r()), ConvertFromHalfFloat (aPixel.g()),
|
||||
ConvertFromHalfFloat (aPixel.b()), ConvertFromHalfFloat (aPixel.a())));
|
||||
}
|
||||
case Image_Format_RGBA:
|
||||
{
|
||||
const Image_ColorRGBA& aPixel = Value<Image_ColorRGBA> (theY, theX);
|
||||
const Image_ColorRGBA& aPixel = *reinterpret_cast<const Image_ColorRGBA*> (theRawValue);
|
||||
return theToLinearize
|
||||
? Quantity_ColorRGBA (Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.r()) / 255.0f),
|
||||
Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.g()) / 255.0f),
|
||||
@@ -319,7 +369,7 @@ Quantity_ColorRGBA Image_PixMap::PixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_BGRA:
|
||||
{
|
||||
const Image_ColorBGRA& aPixel = Value<Image_ColorBGRA> (theY, theX);
|
||||
const Image_ColorBGRA& aPixel = *reinterpret_cast<const Image_ColorBGRA*> (theRawValue);
|
||||
return theToLinearize
|
||||
? Quantity_ColorRGBA (Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.r()) / 255.0f),
|
||||
Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.g()) / 255.0f),
|
||||
@@ -329,7 +379,7 @@ Quantity_ColorRGBA Image_PixMap::PixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_RGB32:
|
||||
{
|
||||
const Image_ColorRGB32& aPixel = Value<Image_ColorRGB32> (theY, theX);
|
||||
const Image_ColorRGB32& aPixel = *reinterpret_cast<const Image_ColorRGB32*> (theRawValue);
|
||||
return theToLinearize
|
||||
? Quantity_ColorRGBA (Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.r()) / 255.0f),
|
||||
Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.g()) / 255.0f),
|
||||
@@ -338,7 +388,7 @@ Quantity_ColorRGBA Image_PixMap::PixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_BGR32:
|
||||
{
|
||||
const Image_ColorBGR32& aPixel = Value<Image_ColorBGR32> (theY, theX);
|
||||
const Image_ColorBGR32& aPixel = *reinterpret_cast<const Image_ColorBGR32*> (theRawValue);
|
||||
return theToLinearize
|
||||
? Quantity_ColorRGBA (Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.r()) / 255.0f),
|
||||
Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.g()) / 255.0f),
|
||||
@@ -347,7 +397,7 @@ Quantity_ColorRGBA Image_PixMap::PixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_RGB:
|
||||
{
|
||||
const Image_ColorRGB& aPixel = Value<Image_ColorRGB> (theY, theX);
|
||||
const Image_ColorRGB& aPixel = *reinterpret_cast<const Image_ColorRGB*> (theRawValue);
|
||||
return theToLinearize
|
||||
? Quantity_ColorRGBA (Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.r()) / 255.0f),
|
||||
Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.g()) / 255.0f),
|
||||
@@ -356,7 +406,7 @@ Quantity_ColorRGBA Image_PixMap::PixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_BGR:
|
||||
{
|
||||
const Image_ColorBGR& aPixel = Value<Image_ColorBGR> (theY, theX);
|
||||
const Image_ColorBGR& aPixel = *reinterpret_cast<const Image_ColorBGR*> (theRawValue);
|
||||
return theToLinearize
|
||||
? Quantity_ColorRGBA (Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.r()) / 255.0f),
|
||||
Quantity_Color::Convert_sRGB_To_LinearRGB (float(aPixel.g()) / 255.0f),
|
||||
@@ -365,14 +415,21 @@ Quantity_ColorRGBA Image_PixMap::PixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_Gray:
|
||||
{
|
||||
const Standard_Byte& aPixel = Value<Standard_Byte> (theY, theX);
|
||||
return Quantity_ColorRGBA (float(aPixel) / 255.0f, float(aPixel) / 255.0f, float(aPixel) / 255.0f, 1.0f); // opaque
|
||||
const Standard_Byte& aPixel = *reinterpret_cast<const Standard_Byte*> (theRawValue);
|
||||
const float anIntensity = float(aPixel) / 255.0f;
|
||||
return Quantity_ColorRGBA (anIntensity, anIntensity, anIntensity, 1.0f); // opaque
|
||||
}
|
||||
case Image_Format_Alpha:
|
||||
{
|
||||
const Standard_Byte& aPixel = Value<Standard_Byte> (theY, theX);
|
||||
const Standard_Byte& aPixel = *reinterpret_cast<const Standard_Byte*> (theRawValue);
|
||||
return Quantity_ColorRGBA (1.0f, 1.0f, 1.0f, float(aPixel) / 255.0f);
|
||||
}
|
||||
case Image_Format_Gray16:
|
||||
{
|
||||
const uint16_t& aPixel = *reinterpret_cast<const uint16_t*> (theRawValue);
|
||||
const float anIntensity = float(aPixel) / 65535.0f;
|
||||
return Quantity_ColorRGBA (anIntensity, anIntensity, anIntensity, 1.0f); // opaque
|
||||
}
|
||||
case Image_Format_UNKNOWN:
|
||||
{
|
||||
break;
|
||||
@@ -384,44 +441,37 @@ Quantity_ColorRGBA Image_PixMap::PixelColor (const Standard_Integer theX,
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetPixelColor
|
||||
// function : ColorToRawPixel
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Quantity_ColorRGBA& theColor,
|
||||
const Standard_Boolean theToDeLinearize)
|
||||
void Image_PixMap::ColorToRawPixel (Standard_Byte* theRawValue,
|
||||
const Image_Format theFormat,
|
||||
const Quantity_ColorRGBA& theColor,
|
||||
const Standard_Boolean theToDeLinearize)
|
||||
{
|
||||
if (IsEmpty()
|
||||
|| theX < 0 || Standard_Size(theX) >= SizeX()
|
||||
|| theY < 0 || Standard_Size(theY) >= SizeY())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const NCollection_Vec4<float>& aColor = theColor;
|
||||
switch (myImgFormat)
|
||||
switch (theFormat)
|
||||
{
|
||||
case Image_Format_GrayF:
|
||||
{
|
||||
ChangeValue<Standard_ShortReal> (theY, theX) = aColor.r();
|
||||
*reinterpret_cast<Standard_ShortReal*> (theRawValue) = aColor.r();
|
||||
return;
|
||||
}
|
||||
case Image_Format_AlphaF:
|
||||
{
|
||||
ChangeValue<Standard_ShortReal> (theY, theX) = aColor.a();
|
||||
*reinterpret_cast<Standard_ShortReal*> (theRawValue) = aColor.a();
|
||||
return;
|
||||
}
|
||||
case Image_Format_RGF:
|
||||
{
|
||||
Image_ColorRGF& aPixel = ChangeValue<Image_ColorRGF> (theY, theX);
|
||||
Image_ColorRGF& aPixel = *reinterpret_cast<Image_ColorRGF*> (theRawValue);
|
||||
aPixel.r() = aColor.r();
|
||||
aPixel.g() = aColor.g();
|
||||
return;
|
||||
}
|
||||
case Image_Format_RGBAF:
|
||||
{
|
||||
Image_ColorRGBAF& aPixel = ChangeValue<Image_ColorRGBAF> (theY, theX);
|
||||
Image_ColorRGBAF& aPixel = *reinterpret_cast<Image_ColorRGBAF*> (theRawValue);
|
||||
aPixel.r() = aColor.r();
|
||||
aPixel.g() = aColor.g();
|
||||
aPixel.b() = aColor.b();
|
||||
@@ -430,7 +480,7 @@ void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_BGRAF:
|
||||
{
|
||||
Image_ColorBGRAF& aPixel = ChangeValue<Image_ColorBGRAF> (theY, theX);
|
||||
Image_ColorBGRAF& aPixel = *reinterpret_cast<Image_ColorBGRAF*> (theRawValue);
|
||||
aPixel.r() = aColor.r();
|
||||
aPixel.g() = aColor.g();
|
||||
aPixel.b() = aColor.b();
|
||||
@@ -439,7 +489,7 @@ void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_RGBF:
|
||||
{
|
||||
Image_ColorRGBF& aPixel = ChangeValue<Image_ColorRGBF> (theY, theX);
|
||||
Image_ColorRGBF& aPixel = *reinterpret_cast<Image_ColorRGBF*> (theRawValue);
|
||||
aPixel.r() = aColor.r();
|
||||
aPixel.g() = aColor.g();
|
||||
aPixel.b() = aColor.b();
|
||||
@@ -447,22 +497,28 @@ void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_BGRF:
|
||||
{
|
||||
Image_ColorBGRF& aPixel = ChangeValue<Image_ColorBGRF> (theY, theX);
|
||||
Image_ColorBGRF& aPixel = *reinterpret_cast<Image_ColorBGRF*> (theRawValue);
|
||||
aPixel.r() = aColor.r();
|
||||
aPixel.g() = aColor.g();
|
||||
aPixel.b() = aColor.b();
|
||||
return;
|
||||
}
|
||||
case Image_Format_GrayF_half:
|
||||
{
|
||||
uint16_t& aPixel = *reinterpret_cast<uint16_t*> (theRawValue);
|
||||
aPixel = ConvertToHalfFloat (aColor.r());
|
||||
return;
|
||||
}
|
||||
case Image_Format_RGF_half:
|
||||
{
|
||||
NCollection_Vec2<uint16_t>& aPixel = ChangeValue<NCollection_Vec2<uint16_t>> (theY, theX);
|
||||
NCollection_Vec2<uint16_t>& aPixel = *reinterpret_cast<NCollection_Vec2<uint16_t>*> (theRawValue);
|
||||
aPixel.x() = ConvertToHalfFloat (aColor.r());
|
||||
aPixel.y() = ConvertToHalfFloat (aColor.g());
|
||||
return;
|
||||
}
|
||||
case Image_Format_RGBAF_half:
|
||||
{
|
||||
NCollection_Vec4<uint16_t>& aPixel = ChangeValue<NCollection_Vec4<uint16_t>> (theY, theX);
|
||||
NCollection_Vec4<uint16_t>& aPixel = *reinterpret_cast<NCollection_Vec4<uint16_t>*> (theRawValue);
|
||||
aPixel.r() = ConvertToHalfFloat (aColor.r());
|
||||
aPixel.g() = ConvertToHalfFloat (aColor.g());
|
||||
aPixel.b() = ConvertToHalfFloat (aColor.b());
|
||||
@@ -471,7 +527,7 @@ void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_RGBA:
|
||||
{
|
||||
Image_ColorRGBA& aPixel = ChangeValue<Image_ColorRGBA> (theY, theX);
|
||||
Image_ColorRGBA& aPixel = *reinterpret_cast<Image_ColorRGBA*> (theRawValue);
|
||||
if (theToDeLinearize)
|
||||
{
|
||||
aPixel.r() = Standard_Byte(Quantity_Color::Convert_LinearRGB_To_sRGB (aColor.r()) * 255.0f);
|
||||
@@ -489,7 +545,7 @@ void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_BGRA:
|
||||
{
|
||||
Image_ColorBGRA& aPixel = ChangeValue<Image_ColorBGRA> (theY, theX);
|
||||
Image_ColorBGRA& aPixel = *reinterpret_cast<Image_ColorBGRA*> (theRawValue);
|
||||
if (theToDeLinearize)
|
||||
{
|
||||
aPixel.r() = Standard_Byte(Quantity_Color::Convert_LinearRGB_To_sRGB (aColor.r()) * 255.0f);
|
||||
@@ -507,7 +563,7 @@ void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_RGB32:
|
||||
{
|
||||
Image_ColorRGB32& aPixel = ChangeValue<Image_ColorRGB32> (theY, theX);
|
||||
Image_ColorRGB32& aPixel = *reinterpret_cast<Image_ColorRGB32*> (theRawValue);
|
||||
if (theToDeLinearize)
|
||||
{
|
||||
aPixel.r() = Standard_Byte(Quantity_Color::Convert_LinearRGB_To_sRGB (aColor.r()) * 255.0f);
|
||||
@@ -525,7 +581,7 @@ void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_BGR32:
|
||||
{
|
||||
Image_ColorBGR32& aPixel = ChangeValue<Image_ColorBGR32> (theY, theX);
|
||||
Image_ColorBGR32& aPixel = *reinterpret_cast<Image_ColorBGR32*> (theRawValue);
|
||||
if (theToDeLinearize)
|
||||
{
|
||||
aPixel.r() = Standard_Byte(Quantity_Color::Convert_LinearRGB_To_sRGB (aColor.r()) * 255.0f);
|
||||
@@ -543,7 +599,7 @@ void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_RGB:
|
||||
{
|
||||
Image_ColorRGB& aPixel = ChangeValue<Image_ColorRGB> (theY, theX);
|
||||
Image_ColorRGB& aPixel = *reinterpret_cast<Image_ColorRGB*> (theRawValue);
|
||||
if (theToDeLinearize)
|
||||
{
|
||||
aPixel.r() = Standard_Byte(Quantity_Color::Convert_LinearRGB_To_sRGB (aColor.r()) * 255.0f);
|
||||
@@ -560,7 +616,7 @@ void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_BGR:
|
||||
{
|
||||
Image_ColorBGR& aPixel = ChangeValue<Image_ColorBGR> (theY, theX);
|
||||
Image_ColorBGR& aPixel = *reinterpret_cast<Image_ColorBGR*> (theRawValue);
|
||||
if (theToDeLinearize)
|
||||
{
|
||||
aPixel.r() = Standard_Byte(Quantity_Color::Convert_LinearRGB_To_sRGB (aColor.r()) * 255.0f);
|
||||
@@ -577,12 +633,17 @@ void Image_PixMap::SetPixelColor (const Standard_Integer theX,
|
||||
}
|
||||
case Image_Format_Gray:
|
||||
{
|
||||
ChangeValue<Standard_Byte> (theY, theX) = Standard_Byte(aColor.r() * 255.0f);
|
||||
*reinterpret_cast<Standard_Byte*>(theRawValue) = Standard_Byte(aColor.r() * 255.0f);
|
||||
return;
|
||||
}
|
||||
case Image_Format_Alpha:
|
||||
{
|
||||
ChangeValue<Standard_Byte> (theY, theX) = Standard_Byte(aColor.a() * 255.0f);
|
||||
*reinterpret_cast<Standard_Byte*>(theRawValue) = Standard_Byte(aColor.a() * 255.0f);
|
||||
return;
|
||||
}
|
||||
case Image_Format_Gray16:
|
||||
{
|
||||
*reinterpret_cast<uint16_t*>(theRawValue) = uint16_t(aColor.r() * 65535.0f);
|
||||
return;
|
||||
}
|
||||
case Image_Format_UNKNOWN:
|
||||
@@ -607,18 +668,21 @@ bool Image_PixMap::SwapRgbaBgra (Image_PixMap& theImage)
|
||||
{
|
||||
const bool toResetAlpha = theImage.Format() == Image_Format_BGR32
|
||||
|| theImage.Format() == Image_Format_RGB32;
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
for (Standard_Size aSlice = 0; aSlice < theImage.SizeZ(); ++aSlice)
|
||||
{
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
{
|
||||
Image_ColorRGBA& aPixel = theImage.ChangeValue<Image_ColorRGBA> (aRow, aCol);
|
||||
Image_ColorBGRA aPixelCopy = theImage.Value <Image_ColorBGRA> (aRow, aCol);
|
||||
aPixel.r() = aPixelCopy.r();
|
||||
aPixel.g() = aPixelCopy.g();
|
||||
aPixel.b() = aPixelCopy.b();
|
||||
if (toResetAlpha)
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
{
|
||||
aPixel.a() = 255;
|
||||
Image_ColorRGBA& aPixel = theImage.ChangeValueXYZ<Image_ColorRGBA> (aCol, aRow, aSlice);
|
||||
Image_ColorBGRA aPixelCopy = theImage.ValueXYZ <Image_ColorBGRA> (aCol, aRow, aSlice);
|
||||
aPixel.r() = aPixelCopy.r();
|
||||
aPixel.g() = aPixelCopy.g();
|
||||
aPixel.b() = aPixelCopy.b();
|
||||
if (toResetAlpha)
|
||||
{
|
||||
aPixel.a() = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -627,15 +691,18 @@ bool Image_PixMap::SwapRgbaBgra (Image_PixMap& theImage)
|
||||
case Image_Format_BGR:
|
||||
case Image_Format_RGB:
|
||||
{
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
for (Standard_Size aSlice = 0; aSlice < theImage.SizeZ(); ++aSlice)
|
||||
{
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
{
|
||||
Image_ColorRGB& aPixel = theImage.ChangeValue<Image_ColorRGB> (aRow, aCol);
|
||||
Image_ColorBGR aPixelCopy = theImage.Value <Image_ColorBGR> (aRow, aCol);
|
||||
aPixel.r() = aPixelCopy.r();
|
||||
aPixel.g() = aPixelCopy.g();
|
||||
aPixel.b() = aPixelCopy.b();
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
{
|
||||
Image_ColorRGB& aPixel = theImage.ChangeValueXYZ<Image_ColorRGB> (aCol, aRow, aSlice);
|
||||
Image_ColorBGR aPixelCopy = theImage.ValueXYZ <Image_ColorBGR> (aCol, aRow, aSlice);
|
||||
aPixel.r() = aPixelCopy.r();
|
||||
aPixel.g() = aPixelCopy.g();
|
||||
aPixel.b() = aPixelCopy.b();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -645,15 +712,18 @@ bool Image_PixMap::SwapRgbaBgra (Image_PixMap& theImage)
|
||||
case Image_Format_BGRAF:
|
||||
case Image_Format_RGBAF:
|
||||
{
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
for (Standard_Size aSlice = 0; aSlice < theImage.SizeZ(); ++aSlice)
|
||||
{
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
{
|
||||
Image_ColorRGBF& aPixel = theImage.ChangeValue<Image_ColorRGBF> (aRow, aCol);
|
||||
Image_ColorBGRF aPixelCopy = theImage.Value <Image_ColorBGRF> (aRow, aCol);
|
||||
aPixel.r() = aPixelCopy.r();
|
||||
aPixel.g() = aPixelCopy.g();
|
||||
aPixel.b() = aPixelCopy.b();
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
{
|
||||
Image_ColorRGBF& aPixel = theImage.ChangeValueXYZ<Image_ColorRGBF> (aCol, aRow, aSlice);
|
||||
Image_ColorBGRF aPixelCopy = theImage.ValueXYZ <Image_ColorBGRF> (aCol, aRow, aSlice);
|
||||
aPixel.r() = aPixelCopy.r();
|
||||
aPixel.g() = aPixelCopy.g();
|
||||
aPixel.b() = aPixelCopy.b();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -673,14 +743,35 @@ void Image_PixMap::ToBlackWhite (Image_PixMap& theImage)
|
||||
case Image_Format_Gray:
|
||||
case Image_Format_Alpha:
|
||||
{
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
for (Standard_Size aSlice = 0; aSlice < theImage.SizeZ(); ++aSlice)
|
||||
{
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
{
|
||||
unsigned char& aPixel = theImage.ChangeValue<unsigned char> (aRow, aCol);
|
||||
if (aPixel != 0)
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
{
|
||||
aPixel = 255;
|
||||
uint8_t& aPixel = theImage.ChangeValueXYZ<uint8_t> (aCol, aRow, aSlice);
|
||||
if (aPixel != 0)
|
||||
{
|
||||
aPixel = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Image_Format_Gray16:
|
||||
{
|
||||
for (Standard_Size aSlice = 0; aSlice < theImage.SizeZ(); ++aSlice)
|
||||
{
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
{
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
{
|
||||
uint16_t& aPixel = theImage.ChangeValueXYZ<uint16_t> (aCol, aRow, aSlice);
|
||||
if (aPixel != 0)
|
||||
{
|
||||
aPixel = 65535;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -693,17 +784,20 @@ void Image_PixMap::ToBlackWhite (Image_PixMap& theImage)
|
||||
case Image_Format_RGBA:
|
||||
case Image_Format_BGRA:
|
||||
{
|
||||
const NCollection_Vec3<unsigned char> aWhite24 (255, 255, 255);
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
const NCollection_Vec3<uint8_t> aWhite24 (255, 255, 255);
|
||||
for (Standard_Size aSlice = 0; aSlice < theImage.SizeZ(); ++aSlice)
|
||||
{
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
{
|
||||
NCollection_Vec3<unsigned char>& aPixel = theImage.ChangeValue< NCollection_Vec3<unsigned char> > (aRow, aCol);
|
||||
if (aPixel[0] != 0
|
||||
|| aPixel[1] != 0
|
||||
|| aPixel[2] != 0)
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
{
|
||||
aPixel = aWhite24;
|
||||
NCollection_Vec3<uint8_t>& aPixel = theImage.ChangeValueXYZ< NCollection_Vec3<uint8_t> > (aCol, aRow, aSlice);
|
||||
if (aPixel[0] != 0
|
||||
|| aPixel[1] != 0
|
||||
|| aPixel[2] != 0)
|
||||
{
|
||||
aPixel = aWhite24;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -712,17 +806,21 @@ void Image_PixMap::ToBlackWhite (Image_PixMap& theImage)
|
||||
default:
|
||||
{
|
||||
const Quantity_ColorRGBA aWhiteRgba (1.0f, 1.0f, 1.0f, 1.0f);
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
for (Standard_Size aSlice = 0; aSlice < theImage.SizeZ(); ++aSlice)
|
||||
{
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||
{
|
||||
const Quantity_ColorRGBA aPixelRgba = theImage.PixelColor (Standard_Integer(aCol), Standard_Integer(aRow));
|
||||
const NCollection_Vec4<float>& aPixel = aPixelRgba;
|
||||
if (aPixel[0] != 0.0f
|
||||
|| aPixel[1] != 0.0f
|
||||
|| aPixel[2] != 0.0f)
|
||||
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||
{
|
||||
theImage.SetPixelColor (int(aCol), int(aRow), aWhiteRgba);
|
||||
Standard_Byte* aRawPixel = theImage.ChangeRawValueXYZ (aCol, aRow, aSlice);
|
||||
const Quantity_ColorRGBA aPixelRgba = ColorFromRawPixel (aRawPixel, theImage.Format());
|
||||
const NCollection_Vec4<float>& aPixel = aPixelRgba;
|
||||
if (aPixel[0] != 0.0f
|
||||
|| aPixel[1] != 0.0f
|
||||
|| aPixel[2] != 0.0f)
|
||||
{
|
||||
ColorToRawPixel (aRawPixel, theImage.Format(), aWhiteRgba);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -732,7 +830,7 @@ void Image_PixMap::ToBlackWhite (Image_PixMap& theImage)
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitCopy
|
||||
// function : FlipY
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Image_PixMap::FlipY (Image_PixMap& theImage)
|
||||
@@ -753,13 +851,16 @@ bool Image_PixMap::FlipY (Image_PixMap& theImage)
|
||||
|
||||
// for odd height middle row should be left as is
|
||||
Standard_Size aNbRowsHalf = theImage.SizeY() / 2;
|
||||
for (Standard_Size aRowT = 0, aRowB = theImage.SizeY() - 1; aRowT < aNbRowsHalf; ++aRowT, --aRowB)
|
||||
for (Standard_Size aSlice = 0; aSlice < theImage.SizeZ(); ++aSlice)
|
||||
{
|
||||
Standard_Byte* aTop = theImage.ChangeRow (aRowT);
|
||||
Standard_Byte* aBot = theImage.ChangeRow (aRowB);
|
||||
memcpy (aTmp.ChangeData(), aTop, aRowSize);
|
||||
memcpy (aTop, aBot, aRowSize);
|
||||
memcpy (aBot, aTmp.Data(), aRowSize);
|
||||
for (Standard_Size aRowT = 0, aRowB = theImage.SizeY() - 1; aRowT < aNbRowsHalf; ++aRowT, --aRowB)
|
||||
{
|
||||
Standard_Byte* aTop = theImage.ChangeSliceRow (aSlice, aRowT);
|
||||
Standard_Byte* aBot = theImage.ChangeSliceRow (aSlice, aRowB);
|
||||
memcpy (aTmp.ChangeData(), aTop, aRowSize);
|
||||
memcpy (aTop, aBot, aRowSize);
|
||||
memcpy (aBot, aTmp.Data(), aRowSize);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -35,6 +35,9 @@ public:
|
||||
return !aUnion.myChar[0];
|
||||
}
|
||||
|
||||
//! Return bytes reserved for one pixel (may include extra bytes for alignment).
|
||||
Standard_EXPORT static Standard_Size SizePixelBytes (const Image_Format thePixelFormat);
|
||||
|
||||
//! Auxiliary method for swapping bytes between RGB and BGR formats.
|
||||
//! This method modifies the image data but does not change pixel format!
|
||||
//! Method will fail if pixel format is not one of the following:
|
||||
@@ -60,8 +63,28 @@ public:
|
||||
//! Return string representation of compressed pixel format.
|
||||
Standard_EXPORT static Standard_CString ImageFormatToString (Image_CompressedFormat theFormat);
|
||||
|
||||
//! Convert raw pixel value into Quantity_ColorRGBA. This function is relatively slow.
|
||||
//! @param[in] theRawValue pointer to pixel definition
|
||||
//! @param[in] theFormat pixel format
|
||||
//! @param[in] theToLinearize when TRUE, the color stored in non-linear color space (e.g. Image_Format_RGB) will be linearized
|
||||
//! @return the pixel color
|
||||
Standard_EXPORT static Quantity_ColorRGBA ColorFromRawPixel (const Standard_Byte* theRawValue,
|
||||
const Image_Format theFormat,
|
||||
const Standard_Boolean theToLinearize = false);
|
||||
|
||||
//! Set raw pixel value from Quantity_ColorRGBA. This function is relatively slow.
|
||||
//! @param[out] theRawValue pointer to pixel definition to modify
|
||||
//! @param[in] theFormat pixel format
|
||||
//! @param[in] theColor color value to convert from
|
||||
//! @param[in] theToDeLinearize when TRUE, the gamma correction will be applied for storing in non-linear color space (e.g. Image_Format_RGB)
|
||||
Standard_EXPORT static void ColorToRawPixel (Standard_Byte* theRawValue,
|
||||
const Image_Format theFormat,
|
||||
const Quantity_ColorRGBA& theColor,
|
||||
const Standard_Boolean theToDeLinearize = false);
|
||||
|
||||
public: // high-level API
|
||||
|
||||
//! Return pixel format.
|
||||
Image_Format Format() const { return myImgFormat; }
|
||||
|
||||
//! Override pixel format specified by InitXXX() methods.
|
||||
@@ -70,41 +93,38 @@ public: // high-level API
|
||||
//! (e.g. ImgGray and ImgAlpha).
|
||||
Standard_EXPORT void SetFormat (const Image_Format thePixelFormat);
|
||||
|
||||
//! @return image width in pixels
|
||||
inline Standard_Size Width() const
|
||||
//! Return image width in pixels.
|
||||
Standard_Size Width() const { return myData.SizeX; }
|
||||
|
||||
//! Return image height in pixels.
|
||||
Standard_Size Height() const { return myData.SizeY; }
|
||||
|
||||
//! Return image depth in pixels.
|
||||
Standard_Size Depth() const { return myData.SizeZ; }
|
||||
|
||||
//! Return image width in pixels.
|
||||
Standard_Size SizeX() const { return myData.SizeX; }
|
||||
|
||||
//! Return image height in pixels.
|
||||
Standard_Size SizeY() const { return myData.SizeY; }
|
||||
|
||||
//! Return image depth in pixels.
|
||||
Standard_Size SizeZ() const { return myData.SizeZ; }
|
||||
|
||||
//! Return image width x height x depth in pixels.
|
||||
NCollection_Vec3<Standard_Size> SizeXYZ() const
|
||||
{
|
||||
return myData.SizeX;
|
||||
return NCollection_Vec3<Standard_Size> (myData.SizeX, myData.SizeY, myData.SizeZ);
|
||||
}
|
||||
|
||||
//! @return image height in pixels
|
||||
inline Standard_Size Height() const
|
||||
{
|
||||
return myData.SizeY;
|
||||
}
|
||||
|
||||
//! @return image width in pixels
|
||||
inline Standard_Size SizeX() const
|
||||
{
|
||||
return myData.SizeX;
|
||||
}
|
||||
|
||||
//! @return image height in pixels
|
||||
inline Standard_Size SizeY() const
|
||||
{
|
||||
return myData.SizeY;
|
||||
}
|
||||
|
||||
//! @return width / height.
|
||||
inline Standard_Real Ratio() const
|
||||
//! Return width / height.
|
||||
Standard_Real Ratio() const
|
||||
{
|
||||
return (SizeY() > 0) ? (Standard_Real(SizeX()) / Standard_Real(SizeY())) : 1.0;
|
||||
}
|
||||
|
||||
//! @return true if data is NULL.
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return myData.IsEmpty();
|
||||
}
|
||||
//! Return true if data is NULL.
|
||||
bool IsEmpty() const { return myData.IsEmpty(); }
|
||||
|
||||
//! Empty constructor. Initialize the NULL image plane.
|
||||
Standard_EXPORT Image_PixMap();
|
||||
@@ -114,38 +134,60 @@ public: // high-level API
|
||||
|
||||
//! Returns the pixel color. This function is relatively slow.
|
||||
//! Beware that this method takes coordinates in opposite order in contrast to ::Value() and ::ChangeValue().
|
||||
//! @param theX [in] column index from left
|
||||
//! @param theY [in] row index from top
|
||||
//! @param theToLinearize [in] when TRUE, the color stored in non-linear color space (e.g. Image_Format_RGB) will be linearized
|
||||
//! @param[in] theX column index from left, starting from 0
|
||||
//! @param[in] theY row index from top, starting from 0
|
||||
//! @param[in] theToLinearize when TRUE, the color stored in non-linear color space (e.g. Image_Format_RGB) will be linearized
|
||||
//! @return the pixel color
|
||||
Standard_EXPORT Quantity_ColorRGBA PixelColor (const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Standard_Boolean theToLinearize = Standard_False) const;
|
||||
Quantity_ColorRGBA PixelColor (Standard_Integer theX,
|
||||
Standard_Integer theY,
|
||||
Standard_Boolean theToLinearize = false) const
|
||||
{
|
||||
if (IsEmpty()
|
||||
|| theX < 0 || (Standard_Size )theX >= SizeX()
|
||||
|| theY < 0 || (Standard_Size )theY >= SizeY())
|
||||
{
|
||||
return Quantity_ColorRGBA (0.0f, 0.0f, 0.0f, 0.0f); // transparent
|
||||
}
|
||||
|
||||
const Standard_Byte* aRawPixel = RawValueXY (theX, theY);
|
||||
return ColorFromRawPixel (aRawPixel, myImgFormat, theToLinearize);
|
||||
}
|
||||
|
||||
//! Sets the pixel color. This function is relatively slow.
|
||||
//! Beware that this method takes coordinates in opposite order in contrast to ::Value() and ::ChangeValue().
|
||||
//! @param theX [in] column index from left
|
||||
//! @param theY [in] row index from top
|
||||
//! @param theColor [in] color to store
|
||||
//! @param theToDeLinearize [in] when TRUE, the gamma correction will be applied for storing in non-linear color space (e.g. Image_Format_RGB)
|
||||
//! @param[in] theX column index from left
|
||||
//! @param[in] theY row index from top
|
||||
//! @param[in] theColor color to store
|
||||
//! @param[in] theToDeLinearize when TRUE, the gamma correction will be applied for storing in non-linear color space (e.g. Image_Format_RGB)
|
||||
void SetPixelColor (const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Quantity_Color& theColor,
|
||||
const Standard_Boolean theToDeLinearize = Standard_False)
|
||||
const Standard_Boolean theToDeLinearize = false)
|
||||
{
|
||||
SetPixelColor (theX, theY, Quantity_ColorRGBA (theColor, 1.0f), theToDeLinearize);
|
||||
}
|
||||
|
||||
//! Sets the pixel color. This function is relatively slow.
|
||||
//! Beware that this method takes coordinates in opposite order in contrast to ::Value() and ::ChangeValue().
|
||||
//! @param theX [in] column index from left
|
||||
//! @param theY [in] row index from top
|
||||
//! @param theColor [in] color to store
|
||||
//! @param theToDeLinearize [in] when TRUE, the gamma correction will be applied for storing in non-linear color space (e.g. Image_Format_RGB)
|
||||
Standard_EXPORT void SetPixelColor (const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Quantity_ColorRGBA& theColor,
|
||||
const Standard_Boolean theToDeLinearize = Standard_False);
|
||||
//! @param[in] theX column index from left
|
||||
//! @param[in] theY row index from top
|
||||
//! @param[in] theColor color to store
|
||||
//! @param[in] theToDeLinearize when TRUE, the gamma correction will be applied for storing in non-linear color space (e.g. Image_Format_RGB)
|
||||
void SetPixelColor (const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Quantity_ColorRGBA& theColor,
|
||||
const Standard_Boolean theToDeLinearize = false)
|
||||
{
|
||||
if (IsEmpty()
|
||||
|| theX < 0 || Standard_Size(theX) >= SizeX()
|
||||
|| theY < 0 || Standard_Size(theY) >= SizeY())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Byte* aRawPixel = ChangeRawValueXY (theX, theY);
|
||||
ColorToRawPixel (aRawPixel, myImgFormat, theColor, theToDeLinearize);
|
||||
}
|
||||
|
||||
//! Initialize image plane as wrapper over alien data.
|
||||
//! Data will not be copied! Notice that caller should ensure
|
||||
@@ -170,15 +212,42 @@ public: // high-level API
|
||||
|
||||
//! Initialize image plane with required dimensions.
|
||||
//! Buffer will be zeroed (black color for most formats).
|
||||
Standard_EXPORT bool InitZero (Image_Format thePixelFormat,
|
||||
const Standard_Size theSizeX,
|
||||
const Standard_Size theSizeY,
|
||||
const Standard_Size theSizeRowBytes = 0,
|
||||
const Standard_Byte theValue = 0);
|
||||
bool InitZero (Image_Format thePixelFormat,
|
||||
const Standard_Size theSizeX,
|
||||
const Standard_Size theSizeY,
|
||||
const Standard_Size theSizeRowBytes = 0,
|
||||
const Standard_Byte theValue = 0)
|
||||
{
|
||||
return InitZero3D (thePixelFormat, NCollection_Vec3<Standard_Size> (theSizeX, theSizeY, 1), theSizeRowBytes, theValue);
|
||||
}
|
||||
|
||||
//! Method correctly deallocate internal buffer.
|
||||
Standard_EXPORT virtual void Clear();
|
||||
|
||||
public:
|
||||
|
||||
//! Initialize 2D/3D image as wrapper over alien data.
|
||||
//! Data will not be copied! Notice that caller should ensure
|
||||
//! that data pointer will not be released during this wrapper lifetime.
|
||||
//! You may call InitCopy() to perform data copying.
|
||||
Standard_EXPORT virtual bool InitWrapper3D (Image_Format thePixelFormat,
|
||||
Standard_Byte* theDataPtr,
|
||||
const NCollection_Vec3<Standard_Size>& theSizeXYZ,
|
||||
const Standard_Size theSizeRowBytes = 0);
|
||||
|
||||
//! Initialize 2D/3D image with required dimensions.
|
||||
//! Memory will be left uninitialized (performance trick).
|
||||
Standard_EXPORT virtual bool InitTrash3D (Image_Format thePixelFormat,
|
||||
const NCollection_Vec3<Standard_Size>& theSizeXYZ,
|
||||
const Standard_Size theSizeRowBytes = 0);
|
||||
|
||||
//! Initialize 2D/3D image with required dimensions.
|
||||
//! Buffer will be zeroed (black color for most formats).
|
||||
Standard_EXPORT bool InitZero3D (Image_Format thePixelFormat,
|
||||
const NCollection_Vec3<Standard_Size>& theSizeXYZ,
|
||||
const Standard_Size theSizeRowBytes = 0,
|
||||
const Standard_Byte theValue = 0);
|
||||
|
||||
public: //! @name low-level API for batch-processing (pixels reading / comparison / modification)
|
||||
|
||||
//! Returns TRUE if image data is stored from Top to the Down.
|
||||
@@ -190,105 +259,106 @@ public: //! @name low-level API for batch-processing (pixels reading / compariso
|
||||
//! convert input row-index to apply this flag!
|
||||
//! You should use this flag only if interconnect with alien APIs and buffers.
|
||||
//! @return true if image data is top-down
|
||||
inline bool IsTopDown() const
|
||||
{
|
||||
return myData.TopToDown == 1;
|
||||
}
|
||||
bool IsTopDown() const { return myData.TopToDown == 1; }
|
||||
|
||||
//! Setup scanlines order in memory - top-down or bottom-up.
|
||||
//! Drawers should explicitly specify this value if current state IsTopDown() was ignored!
|
||||
//! @param theIsTopDown top-down flag
|
||||
inline void SetTopDown (const bool theIsTopDown)
|
||||
{
|
||||
myData.SetTopDown (theIsTopDown);
|
||||
}
|
||||
void SetTopDown (const bool theIsTopDown) { myData.SetTopDown (theIsTopDown); }
|
||||
|
||||
//! Returns +1 if scanlines ordered in Top->Down order in memory and -1 otherwise.
|
||||
//! @return scanline increment for Top->Down iteration
|
||||
inline Standard_Size TopDownInc() const
|
||||
Standard_Size TopDownInc() const { return myData.TopToDown; }
|
||||
|
||||
//! Return data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.).
|
||||
const Standard_Byte* Data() const { return myData.Data(); }
|
||||
|
||||
//! Return data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.).
|
||||
Standard_Byte* ChangeData() { return myData.ChangeData(); }
|
||||
|
||||
//! Return data pointer to requested row (first column).
|
||||
//! Indexation starts from 0.
|
||||
const Standard_Byte* Row (Standard_Size theRow) const { return myData.Row (theRow); }
|
||||
|
||||
//! Return data pointer to requested row (first column).
|
||||
//! Indexation starts from 0.
|
||||
Standard_Byte* ChangeRow (Standard_Size theRow) { return myData.ChangeRow (theRow); }
|
||||
|
||||
//! Return data pointer to requested 2D slice.
|
||||
//! Indexation starts from 0.
|
||||
const Standard_Byte* Slice (Standard_Size theSlice) const { return myData.Slice (theSlice); }
|
||||
|
||||
//! Return data pointer to requested 2D slice.
|
||||
//! Indexation starts from 0.
|
||||
Standard_Byte* ChangeSlice (Standard_Size theSlice) { return myData.ChangeSlice (theSlice); }
|
||||
|
||||
//! Return data pointer to requested row (first column).
|
||||
//! Indexation starts from 0.
|
||||
const Standard_Byte* SliceRow (Standard_Size theSlice,
|
||||
Standard_Size theRow) const
|
||||
{
|
||||
return myData.TopToDown;
|
||||
return myData.SliceRow (theSlice, theRow);
|
||||
}
|
||||
|
||||
//! @return data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.).
|
||||
inline const Standard_Byte* Data() const
|
||||
//! Return data pointer to requested row (first column).
|
||||
//! Indexation starts from 0.
|
||||
Standard_Byte* ChangeSliceRow (Standard_Size theSlice,
|
||||
Standard_Size theRow)
|
||||
{
|
||||
return myData.Data();
|
||||
return myData.ChangeSliceRow (theSlice, theRow);
|
||||
}
|
||||
|
||||
//! @return data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.).
|
||||
inline Standard_Byte* ChangeData()
|
||||
{
|
||||
return myData.ChangeData();
|
||||
}
|
||||
//! Return bytes reserved for one pixel (may include extra bytes for alignment).
|
||||
Standard_Size SizePixelBytes() const { return myData.SizeBPP; }
|
||||
|
||||
//! @return data pointer to requested row (first column).
|
||||
inline const Standard_Byte* Row (const Standard_Size theRow) const
|
||||
{
|
||||
return myData.Row (theRow);
|
||||
}
|
||||
|
||||
//! @return data pointer to requested row (first column).
|
||||
inline Standard_Byte* ChangeRow (const Standard_Size theRow)
|
||||
{
|
||||
return myData.ChangeRow (theRow);
|
||||
}
|
||||
|
||||
//! @return bytes reserved for one pixel (may include extra bytes for alignment).
|
||||
inline Standard_Size SizePixelBytes() const
|
||||
{
|
||||
return myData.SizeBPP;
|
||||
}
|
||||
|
||||
//! @return bytes reserved for one pixel (may include extra bytes for alignment).
|
||||
Standard_EXPORT static Standard_Size SizePixelBytes (const Image_Format thePixelFormat);
|
||||
|
||||
//! @return bytes reserved per row.
|
||||
//! Return bytes reserved per row.
|
||||
//! Could be larger than needed to store packed row (extra bytes for alignment etc.).
|
||||
inline Standard_Size SizeRowBytes() const
|
||||
{
|
||||
return myData.SizeRowBytes;
|
||||
}
|
||||
Standard_Size SizeRowBytes() const { return myData.SizeRowBytes; }
|
||||
|
||||
//! @return the extra bytes in the row.
|
||||
inline Standard_Size RowExtraBytes() const
|
||||
//! Return the extra bytes in the row.
|
||||
Standard_Size RowExtraBytes() const
|
||||
{
|
||||
return SizeRowBytes() - SizeX() * SizePixelBytes();
|
||||
}
|
||||
|
||||
//! Compute the maximal row alignment for current row size.
|
||||
//! @return maximal row alignment in bytes (up to 16 bytes).
|
||||
inline Standard_Size MaxRowAligmentBytes() const
|
||||
{
|
||||
return myData.MaxRowAligmentBytes();
|
||||
}
|
||||
Standard_Size MaxRowAligmentBytes() const { return myData.MaxRowAligmentBytes(); }
|
||||
|
||||
//! @return buffer size
|
||||
inline Standard_Size SizeBytes() const
|
||||
{
|
||||
return myData.Size();
|
||||
}
|
||||
//! Return number of bytes per 2D slice.
|
||||
Standard_Size SizeSliceBytes() const { return myData.SizeSliceBytes; }
|
||||
|
||||
//! Return buffer size
|
||||
Standard_Size SizeBytes() const { return myData.Size(); }
|
||||
|
||||
public:
|
||||
|
||||
//! Access image pixel with specified color type.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next.
|
||||
template <typename ColorType_t>
|
||||
inline const ColorType_t& Value (const Standard_Size theRow,
|
||||
const Standard_Size theCol) const
|
||||
const ColorType_t& Value (Standard_Size theRow,
|
||||
Standard_Size theCol) const
|
||||
{
|
||||
return *reinterpret_cast<const ColorType_t*>(myData.Value (theRow, theCol));
|
||||
}
|
||||
|
||||
//! Access image pixel with specified color type.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next.
|
||||
template <typename ColorType_t>
|
||||
inline ColorType_t& ChangeValue (const Standard_Size theRow,
|
||||
const Standard_Size theCol)
|
||||
ColorType_t& ChangeValue (Standard_Size theRow,
|
||||
Standard_Size theCol)
|
||||
{
|
||||
return *reinterpret_cast<ColorType_t* >(myData.ChangeValue (theRow, theCol));
|
||||
}
|
||||
|
||||
//! Access image pixel as raw data pointer.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next.
|
||||
const Standard_Byte* RawValue (Standard_Size theRow,
|
||||
Standard_Size theCol) const
|
||||
{
|
||||
@@ -296,13 +366,105 @@ public: //! @name low-level API for batch-processing (pixels reading / compariso
|
||||
}
|
||||
|
||||
//! Access image pixel as raw data pointer.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next.
|
||||
Standard_Byte* ChangeRawValue (Standard_Size theRow,
|
||||
Standard_Size theCol)
|
||||
{
|
||||
return myData.ChangeValue (theRow, theCol);
|
||||
}
|
||||
|
||||
//! Access image pixel with specified color type.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in traditional X, Y order.
|
||||
template <typename ColorType_t>
|
||||
const ColorType_t& ValueXY (Standard_Size theX,
|
||||
Standard_Size theY) const
|
||||
{
|
||||
return *reinterpret_cast<const ColorType_t*>(myData.ValueXY (theX, theY));
|
||||
}
|
||||
|
||||
//! Access image pixel with specified color type.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in traditional X, Y order.
|
||||
template <typename ColorType_t>
|
||||
ColorType_t& ChangeValueXY (Standard_Size theX,
|
||||
Standard_Size theY)
|
||||
{
|
||||
return *reinterpret_cast<ColorType_t* >(myData.ChangeValueXY (theX, theY));
|
||||
}
|
||||
|
||||
//! Access image pixel as raw data pointer.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in traditional X, Y order.
|
||||
const Standard_Byte* RawValueXY (Standard_Size theX,
|
||||
Standard_Size theY) const
|
||||
{
|
||||
return myData.ValueXY (theX, theY);
|
||||
}
|
||||
|
||||
//! Access image pixel as raw data pointer.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in traditional X, Y order.
|
||||
Standard_Byte* ChangeRawValueXY (Standard_Size theX,
|
||||
Standard_Size theY)
|
||||
{
|
||||
return myData.ChangeValueXY (theX, theY);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Access image pixel with specified color type.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in traditional X, Y, Z order.
|
||||
template <typename ColorType_t>
|
||||
const ColorType_t& ValueXYZ (Standard_Size theX,
|
||||
Standard_Size theY,
|
||||
Standard_Size theZ) const
|
||||
{
|
||||
return *reinterpret_cast<const ColorType_t*>(myData.ValueXYZ (theX, theY, theZ));
|
||||
}
|
||||
|
||||
//! Access image pixel with specified color type.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in traditional X, Y, Z order.
|
||||
template <typename ColorType_t>
|
||||
ColorType_t& ChangeValueXYZ (Standard_Size theX,
|
||||
Standard_Size theY,
|
||||
Standard_Size theZ)
|
||||
{
|
||||
return *reinterpret_cast<ColorType_t* >(myData.ChangeValueXYZ (theX, theY, theZ));
|
||||
}
|
||||
|
||||
//! Access image pixel as raw data pointer.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in traditional X, Y, Z order.
|
||||
const Standard_Byte* RawValueXYZ (Standard_Size theX,
|
||||
Standard_Size theY,
|
||||
Standard_Size theZ) const
|
||||
{
|
||||
return myData.ValueXYZ (theX, theY, theZ);
|
||||
}
|
||||
|
||||
//! Access image pixel as raw data pointer.
|
||||
//! Indexation starts from 0.
|
||||
//! This method does not perform any type checks - use on own risk (check Format() before)!
|
||||
//! WARNING: Input parameters are defined in traditional X, Y, Z order.
|
||||
Standard_Byte* ChangeRawValueXYZ (Standard_Size theX,
|
||||
Standard_Size theY,
|
||||
Standard_Size theZ)
|
||||
{
|
||||
return myData.ChangeValueXYZ (theX, theY, theZ);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Convert 16-bit half-float value into 32-bit float (simple conversion).
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <Image_Color.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
#include <NCollection_Vec3.hxx>
|
||||
|
||||
//! Structure to manage image buffer.
|
||||
class Image_PixMapData : public NCollection_Buffer
|
||||
@@ -31,7 +32,9 @@ public:
|
||||
SizeBPP (0),
|
||||
SizeX (0),
|
||||
SizeY (0),
|
||||
SizeZ (0),
|
||||
SizeRowBytes (0),
|
||||
SizeSliceBytes (0),
|
||||
TopToDown (Standard_Size(-1))
|
||||
{
|
||||
//
|
||||
@@ -44,16 +47,28 @@ public:
|
||||
const Standard_Size theSizeY,
|
||||
const Standard_Size theSizeRowBytes,
|
||||
Standard_Byte* theDataPtr)
|
||||
{
|
||||
return Init (theAlloc, theSizeBPP, NCollection_Vec3<Standard_Size> (theSizeX, theSizeY, 1), theSizeRowBytes, theDataPtr);
|
||||
}
|
||||
|
||||
//! Initializer.
|
||||
bool Init (const Handle(NCollection_BaseAllocator)& theAlloc,
|
||||
const Standard_Size theSizeBPP,
|
||||
const NCollection_Vec3<Standard_Size>& theSizeXYZ,
|
||||
const Standard_Size theSizeRowBytes,
|
||||
Standard_Byte* theDataPtr)
|
||||
{
|
||||
SetAllocator (theAlloc); // will free old data as well
|
||||
|
||||
myData = theDataPtr;
|
||||
myTopRowPtr = NULL;
|
||||
SizeBPP = theSizeBPP;
|
||||
SizeX = theSizeX;
|
||||
SizeY = theSizeY;
|
||||
SizeRowBytes = theSizeRowBytes != 0 ? theSizeRowBytes : (theSizeX * theSizeBPP);
|
||||
mySize = SizeRowBytes * SizeY;
|
||||
SizeX = theSizeXYZ.x();
|
||||
SizeY = theSizeXYZ.y();
|
||||
SizeZ = theSizeXYZ.z();
|
||||
SizeRowBytes = theSizeRowBytes != 0 ? theSizeRowBytes : (SizeX * theSizeBPP);
|
||||
SizeSliceBytes = SizeRowBytes * SizeY;
|
||||
mySize = SizeSliceBytes * SizeZ;
|
||||
if (myData == NULL)
|
||||
{
|
||||
Allocate (mySize);
|
||||
@@ -71,35 +86,93 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//! @return data pointer to requested row (first column).
|
||||
inline const Standard_Byte* Row (const Standard_Size theRow) const
|
||||
//! Return data pointer to requested row (first column).
|
||||
const Standard_Byte* Row (const Standard_Size theRow) const
|
||||
{
|
||||
return myTopRowPtr + ptrdiff_t(SizeRowBytes * theRow * TopToDown);
|
||||
}
|
||||
|
||||
//! @return data pointer to requested row (first column).
|
||||
inline Standard_Byte* ChangeRow (const Standard_Size theRow)
|
||||
//! Return data pointer to requested row (first column).
|
||||
Standard_Byte* ChangeRow (const Standard_Size theRow)
|
||||
{
|
||||
return myTopRowPtr + ptrdiff_t(SizeRowBytes * theRow * TopToDown);
|
||||
}
|
||||
|
||||
//! @return data pointer to requested position.
|
||||
inline const Standard_Byte* Value (const Standard_Size theRow,
|
||||
const Standard_Size theCol) const
|
||||
//! Return data pointer to requested position.
|
||||
const Standard_Byte* Value (const Standard_Size theRow,
|
||||
const Standard_Size theCol) const
|
||||
{
|
||||
return myTopRowPtr + ptrdiff_t(SizeRowBytes * theRow * TopToDown) + SizeBPP * theCol;
|
||||
}
|
||||
|
||||
//! @return data pointer to requested position.
|
||||
inline Standard_Byte* ChangeValue (const Standard_Size theRow,
|
||||
const Standard_Size theCol)
|
||||
//! Return data pointer to requested position.
|
||||
Standard_Byte* ChangeValue (Standard_Size theRow,
|
||||
Standard_Size theCol)
|
||||
{
|
||||
return myTopRowPtr + ptrdiff_t(SizeRowBytes * theRow * TopToDown) + SizeBPP * theCol;
|
||||
}
|
||||
|
||||
//! Return data pointer to requested position.
|
||||
const Standard_Byte* ValueXY (Standard_Size theX,
|
||||
Standard_Size theY) const
|
||||
{
|
||||
return myTopRowPtr + ptrdiff_t(SizeRowBytes * theY * TopToDown) + SizeBPP * theX;
|
||||
}
|
||||
|
||||
//! Return data pointer to requested position.
|
||||
Standard_Byte* ChangeValueXY (Standard_Size theX,
|
||||
Standard_Size theY)
|
||||
{
|
||||
return myTopRowPtr + ptrdiff_t(SizeRowBytes * theY * TopToDown) + SizeBPP * theX;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Return data pointer to requested 2D slice.
|
||||
const Standard_Byte* Slice (Standard_Size theSlice) const
|
||||
{
|
||||
return myData + ptrdiff_t(SizeSliceBytes * theSlice);
|
||||
}
|
||||
|
||||
//! Return data pointer to requested 2D slice.
|
||||
Standard_Byte* ChangeSlice (Standard_Size theSlice)
|
||||
{
|
||||
return myData + ptrdiff_t(SizeSliceBytes * theSlice);
|
||||
}
|
||||
|
||||
//! Return data pointer to requested row (first column).
|
||||
const Standard_Byte* SliceRow (Standard_Size theSlice,
|
||||
Standard_Size theRow) const
|
||||
{
|
||||
return myTopRowPtr + ptrdiff_t(SizeRowBytes * theRow * TopToDown) + ptrdiff_t(SizeSliceBytes * theSlice);
|
||||
}
|
||||
|
||||
//! Return data pointer to requested row (first column).
|
||||
Standard_Byte* ChangeSliceRow (Standard_Size theSlice,
|
||||
Standard_Size theRow)
|
||||
{
|
||||
return myTopRowPtr + ptrdiff_t(SizeRowBytes * theRow * TopToDown) + ptrdiff_t(SizeSliceBytes * theSlice);
|
||||
}
|
||||
|
||||
//! Return data pointer to requested position.
|
||||
const Standard_Byte* ValueXYZ (Standard_Size theX,
|
||||
Standard_Size theY,
|
||||
Standard_Size theZ) const
|
||||
{
|
||||
return myTopRowPtr + ptrdiff_t(SizeRowBytes * theY * TopToDown) + SizeBPP * theX + ptrdiff_t(SizeSliceBytes * theZ);
|
||||
}
|
||||
|
||||
//! Return data pointer to requested position.
|
||||
Standard_Byte* ChangeValueXYZ (Standard_Size theX,
|
||||
Standard_Size theY,
|
||||
Standard_Size theZ)
|
||||
{
|
||||
return myTopRowPtr + ptrdiff_t(SizeRowBytes * theY * TopToDown) + SizeBPP * theX + ptrdiff_t(SizeSliceBytes * theZ);
|
||||
}
|
||||
|
||||
//! Compute the maximal row alignment for current row size.
|
||||
//! @return maximal row alignment in bytes (up to 16 bytes).
|
||||
inline Standard_Size MaxRowAligmentBytes() const
|
||||
Standard_Size MaxRowAligmentBytes() const
|
||||
{
|
||||
Standard_Size anAlignment = 2;
|
||||
for (; anAlignment <= 16; anAlignment <<= 1)
|
||||
@@ -115,7 +188,7 @@ public:
|
||||
//! Setup scanlines order in memory - top-down or bottom-up.
|
||||
//! Drawers should explicitly specify this value if current state IsTopDown() was ignored!
|
||||
//! @param theIsTopDown top-down flag
|
||||
inline void SetTopDown (const bool theIsTopDown)
|
||||
void SetTopDown (const bool theIsTopDown)
|
||||
{
|
||||
TopToDown = (theIsTopDown ? 1 : Standard_Size(-1));
|
||||
myTopRowPtr = ((TopToDown == 1 || myData == NULL)
|
||||
@@ -128,16 +201,17 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
Standard_Size SizeBPP; //!< bytes per pixel
|
||||
Standard_Size SizeX; //!< width in pixels
|
||||
Standard_Size SizeY; //!< height in pixels
|
||||
Standard_Size SizeRowBytes; //!< number of bytes per line (in most cases equal to 3 * sizeX)
|
||||
Standard_Size TopToDown; //!< image scanlines direction in memory from Top to the Down
|
||||
|
||||
Standard_Size SizeBPP; //!< bytes per pixel
|
||||
Standard_Size SizeX; //!< width in pixels
|
||||
Standard_Size SizeY; //!< height in pixels
|
||||
Standard_Size SizeZ; //!< depth in pixels
|
||||
Standard_Size SizeRowBytes; //!< number of bytes per line (in most cases equal to 3 * sizeX)
|
||||
Standard_Size SizeSliceBytes; //!< number of bytes per 2D slice
|
||||
Standard_Size TopToDown; //!< image scanlines direction in memory from Top to the Down
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE(Image_PixMapData,NCollection_Buffer) // Type definition
|
||||
DEFINE_STANDARD_RTTIEXT(Image_PixMapData, NCollection_Buffer)
|
||||
|
||||
};
|
||||
|
||||
|
@@ -3,4 +3,3 @@ IntCurvesFace_Intersector.hxx
|
||||
IntCurvesFace_Intersector.lxx
|
||||
IntCurvesFace_ShapeIntersector.cxx
|
||||
IntCurvesFace_ShapeIntersector.hxx
|
||||
IntCurvesFace_ShapeIntersector.lxx
|
||||
|
@@ -43,6 +43,9 @@
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(IntCurvesFace_Intersector, Standard_Transient)
|
||||
|
||||
//
|
||||
static void ComputeSamplePars(const Handle(Adaptor3d_Surface)& Hsurface,
|
||||
const Standard_Integer nbsu,
|
||||
@@ -134,8 +137,6 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
|
||||
done(Standard_False),
|
||||
myReady(Standard_False),
|
||||
nbpnt(0),
|
||||
PtrOnPolyhedron(NULL),
|
||||
PtrOnBndBounding(NULL),
|
||||
myUseBoundTol (UseBToler),
|
||||
myIsParallel(Standard_False)
|
||||
{
|
||||
@@ -201,14 +202,12 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
|
||||
{
|
||||
Handle(TColStd_HArray1OfReal) UPars, VPars;
|
||||
ComputeSamplePars(Hsurface, nbsu, nbsv, UPars, VPars);
|
||||
PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *)
|
||||
new IntCurveSurface_ThePolyhedronOfHInter(Hsurface, UPars->ChangeArray1(),
|
||||
VPars->ChangeArray1());
|
||||
myPolyhedron.reset(new IntCurveSurface_ThePolyhedronOfHInter(Hsurface, UPars->ChangeArray1(),
|
||||
VPars->ChangeArray1()));
|
||||
}
|
||||
else
|
||||
{
|
||||
PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *)
|
||||
new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
|
||||
myPolyhedron.reset(new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1));
|
||||
}
|
||||
}
|
||||
myReady = Standard_True;
|
||||
@@ -218,8 +217,8 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter &HICS,
|
||||
const Standard_Real parinf,
|
||||
const Standard_Real parsup)
|
||||
const Standard_Real parinf,
|
||||
const Standard_Real parsup)
|
||||
{
|
||||
if(HICS.IsDone() && HICS.NbPoints() > 0) {
|
||||
//Calculate tolerance for 2d classifier
|
||||
@@ -282,7 +281,6 @@ void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter &HICS,
|
||||
Standard_Real W = HICSW;
|
||||
IntCurveSurface_TransitionOnCurve transition = HICSPointindex.Transition();
|
||||
gp_Pnt pnt = HICSPointindex.Pnt();
|
||||
// state = currentstate;
|
||||
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
|
||||
Standard_Integer anIntState = (currentstate == TopAbs_IN) ? 0 : 1;
|
||||
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
|
||||
@@ -340,8 +338,8 @@ void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter &HICS,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void IntCurvesFace_Intersector::Perform(const gp_Lin& L,
|
||||
const Standard_Real ParMin,
|
||||
const Standard_Real ParMax)
|
||||
const Standard_Real ParMin,
|
||||
const Standard_Real ParMax)
|
||||
{
|
||||
done = Standard_False;
|
||||
if (!myReady)
|
||||
@@ -360,7 +358,7 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L,
|
||||
Standard_Real parinf=ParMin;
|
||||
Standard_Real parsup=ParMax;
|
||||
//
|
||||
if(PtrOnPolyhedron == NULL) {
|
||||
if(!myPolyhedron) {
|
||||
HICS.Perform(HLL,Hsurface);
|
||||
}
|
||||
else {
|
||||
@@ -368,7 +366,7 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L,
|
||||
Bnd_Box boxLine;
|
||||
bndTool.LinBox
|
||||
(L,
|
||||
((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)->Bounding(),
|
||||
myPolyhedron->Bounding(),
|
||||
boxLine);
|
||||
if(bndTool.NbSegments() == 0)
|
||||
return;
|
||||
@@ -381,8 +379,8 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L,
|
||||
if((psup - pinf)<1e-10) { pinf-=1e-10; psup+=1e-10; }
|
||||
if(nbseg==1) { parinf=pinf; parsup=psup; }
|
||||
else {
|
||||
if(parinf>pinf) parinf = pinf;
|
||||
if(parsup<psup) parsup = psup;
|
||||
if(parinf>pinf) parinf = pinf;
|
||||
if(parsup<psup) parsup = psup;
|
||||
}
|
||||
}
|
||||
if(parinf>ParMax) { return; }
|
||||
@@ -391,28 +389,26 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L,
|
||||
if(parsup>ParMax) parsup=ParMax;
|
||||
if(parinf>(parsup-1e-9)) return;
|
||||
IntCurveSurface_ThePolygonOfHInter polygon(HLL,
|
||||
parinf,
|
||||
parsup,
|
||||
2);
|
||||
parinf,
|
||||
parsup,
|
||||
2);
|
||||
#if OPTIMISATION
|
||||
if(PtrOnBndBounding==NULL) {
|
||||
PtrOnBndBounding = (Bnd_BoundSortBox *) new Bnd_BoundSortBox();
|
||||
IntCurveSurface_ThePolyhedronOfHInter *thePolyh=
|
||||
(IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
|
||||
((Bnd_BoundSortBox *)(PtrOnBndBounding))->
|
||||
Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*thePolyh),
|
||||
IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*thePolyh));
|
||||
if(!myBndBounding)
|
||||
{
|
||||
myBndBounding.reset(new Bnd_BoundSortBox());
|
||||
myBndBounding->Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*myPolyhedron),
|
||||
IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*myPolyhedron));
|
||||
}
|
||||
HICS.Perform(HLL,
|
||||
polygon,
|
||||
Hsurface,
|
||||
*((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron),
|
||||
*((Bnd_BoundSortBox *)PtrOnBndBounding));
|
||||
polygon,
|
||||
Hsurface,
|
||||
*myPolyhedron,
|
||||
*myBndBounding);
|
||||
#else
|
||||
HICS.Perform(HLL,
|
||||
polygon,
|
||||
Hsurface,
|
||||
*((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron));
|
||||
polygon,
|
||||
Hsurface,
|
||||
*myPolyhedron);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -423,8 +419,8 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_Curve)& HCu,
|
||||
const Standard_Real ParMin,
|
||||
const Standard_Real ParMax)
|
||||
const Standard_Real ParMin,
|
||||
const Standard_Real ParMax)
|
||||
{
|
||||
done = Standard_False;
|
||||
if (!myReady)
|
||||
@@ -443,10 +439,12 @@ void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_Curve)& HCu,
|
||||
Standard_Real parinf=ParMin;
|
||||
Standard_Real parsup=ParMax;
|
||||
|
||||
if(PtrOnPolyhedron == NULL) {
|
||||
if(!myPolyhedron)
|
||||
{
|
||||
HICS.Perform(HCu,Hsurface);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
parinf = IntCurveSurface_TheHCurveTool::FirstParameter(HCu);
|
||||
parsup = IntCurveSurface_TheHCurveTool::LastParameter(HCu);
|
||||
if(parinf<ParMin) parinf = ParMin;
|
||||
@@ -456,26 +454,25 @@ void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_Curve)& HCu,
|
||||
nbs = IntCurveSurface_TheHCurveTool::NbSamples(HCu,parinf,parsup);
|
||||
|
||||
IntCurveSurface_ThePolygonOfHInter polygon(HCu,
|
||||
parinf,
|
||||
parsup,
|
||||
nbs);
|
||||
parinf,
|
||||
parsup,
|
||||
nbs);
|
||||
#if OPTIMISATION
|
||||
if(PtrOnBndBounding==NULL) {
|
||||
PtrOnBndBounding = (Bnd_BoundSortBox *) new Bnd_BoundSortBox();
|
||||
IntCurveSurface_ThePolyhedronOfHInter *thePolyh=(IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
|
||||
((Bnd_BoundSortBox *)(PtrOnBndBounding))->Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*thePolyh),
|
||||
IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*thePolyh));
|
||||
if(!myBndBounding) {
|
||||
myBndBounding.reset(new Bnd_BoundSortBox());
|
||||
myBndBounding->Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*myPolyhedron),
|
||||
IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*myPolyhedron));
|
||||
}
|
||||
HICS.Perform(HCu,
|
||||
polygon,
|
||||
Hsurface,
|
||||
*((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron),
|
||||
*((Bnd_BoundSortBox *)PtrOnBndBounding));
|
||||
polygon,
|
||||
Hsurface,
|
||||
*myPolyhedron,
|
||||
*myBndBounding);
|
||||
#else
|
||||
HICS.Perform(HCu,
|
||||
polygon,
|
||||
Hsurface,
|
||||
*((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron));
|
||||
polygon,
|
||||
Hsurface,
|
||||
*myPolyhedron);
|
||||
#endif
|
||||
}
|
||||
InternalCall(HICS,parinf,parsup);
|
||||
@@ -483,37 +480,33 @@ void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_Curve)& HCu,
|
||||
|
||||
//============================================================================
|
||||
Bnd_Box IntCurvesFace_Intersector::Bounding() const {
|
||||
if(PtrOnPolyhedron !=NULL) {
|
||||
return(((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)->Bounding());
|
||||
if(myPolyhedron)
|
||||
{
|
||||
return myPolyhedron->Bounding();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
Bnd_Box B;
|
||||
return(B);
|
||||
return B;
|
||||
}
|
||||
}
|
||||
TopAbs_State IntCurvesFace_Intersector::ClassifyUVPoint(const gp_Pnt2d& Puv) const {
|
||||
|
||||
TopAbs_State IntCurvesFace_Intersector::ClassifyUVPoint(const gp_Pnt2d& Puv) const
|
||||
{
|
||||
TopAbs_State state = myTopolTool->Classify(Puv,1e-7);
|
||||
return(state);
|
||||
}
|
||||
//============================================================================
|
||||
void IntCurvesFace_Intersector::Destroy() {
|
||||
if(PtrOnPolyhedron !=NULL) {
|
||||
delete (IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
|
||||
PtrOnPolyhedron = NULL;
|
||||
}
|
||||
if(PtrOnBndBounding !=NULL) {
|
||||
delete (Bnd_BoundSortBox *)PtrOnBndBounding;
|
||||
PtrOnBndBounding=NULL;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
void IntCurvesFace_Intersector::SetUseBoundToler(Standard_Boolean UseBToler)
|
||||
{
|
||||
myUseBoundTol = UseBToler;
|
||||
}
|
||||
void IntCurvesFace_Intersector::SetUseBoundToler(Standard_Boolean UseBToler)
|
||||
{
|
||||
myUseBoundTol = UseBToler;
|
||||
}
|
||||
|
||||
Standard_Boolean IntCurvesFace_Intersector::GetUseBoundToler() const
|
||||
{
|
||||
return myUseBoundTol;
|
||||
}
|
||||
Standard_Boolean IntCurvesFace_Intersector::GetUseBoundToler() const
|
||||
{
|
||||
return myUseBoundTol;
|
||||
}
|
||||
|
||||
IntCurvesFace_Intersector::~IntCurvesFace_Intersector()
|
||||
{
|
||||
}
|
||||
|
@@ -18,14 +18,18 @@
|
||||
#define _IntCurvesFace_Intersector_HeaderFile
|
||||
|
||||
#include <Adaptor3d_Curve.hxx>
|
||||
#include <Bnd_BoundSortBox.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <IntCurveSurface_SequenceOfPnt.hxx>
|
||||
#include <IntCurveSurface_ThePolyhedronOfHInter.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <GeomAbs_SurfaceType.hxx>
|
||||
#include <IntCurveSurface_TransitionOnCurve.hxx>
|
||||
#include <TopAbs_State.hxx>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class BRepTopAdaptor_TopolTool;
|
||||
class gp_Lin;
|
||||
class gp_Pnt;
|
||||
@@ -33,8 +37,13 @@ class IntCurveSurface_HInter;
|
||||
class gp_Pnt2d;
|
||||
class Bnd_Box;
|
||||
|
||||
class IntCurvesFace_Intersector
|
||||
DEFINE_STANDARD_HANDLE(IntCurvesFace_Intersector, Standard_Transient)
|
||||
|
||||
|
||||
class IntCurvesFace_Intersector : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(IntCurvesFace_Intersector, Standard_Transient)
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
@@ -123,14 +132,7 @@ public:
|
||||
//! Returns the boundary tolerance flag
|
||||
Standard_EXPORT Standard_Boolean GetUseBoundToler() const;
|
||||
|
||||
Standard_EXPORT void Destroy();
|
||||
~IntCurvesFace_Intersector()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Standard_EXPORT virtual ~IntCurvesFace_Intersector();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -153,8 +155,8 @@ private:
|
||||
Standard_Boolean myReady;
|
||||
Standard_Integer nbpnt;
|
||||
TopoDS_Face face;
|
||||
Standard_Address PtrOnPolyhedron;
|
||||
Standard_Address PtrOnBndBounding;
|
||||
std::unique_ptr<IntCurveSurface_ThePolyhedronOfHInter> myPolyhedron;
|
||||
std::unique_ptr<Bnd_BoundSortBox> myBndBounding;
|
||||
Standard_Boolean myUseBoundTol;
|
||||
Standard_Boolean myIsParallel; //Curve is "parallel" face surface
|
||||
//This case is recognized only for some pairs
|
||||
|
@@ -30,202 +30,186 @@
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
//-- ================================================================================
|
||||
IntCurvesFace_ShapeIntersector::IntCurvesFace_ShapeIntersector() {
|
||||
nbfaces=0;
|
||||
done=Standard_False;
|
||||
PtrJetons=NULL;
|
||||
PtrJetonsIndex=NULL;
|
||||
|
||||
IntCurvesFace_ShapeIntersector::IntCurvesFace_ShapeIntersector()
|
||||
: myIsDone(Standard_False),
|
||||
myNbFaces(0)
|
||||
{
|
||||
}
|
||||
//-- ================================================================================
|
||||
void IntCurvesFace_ShapeIntersector::Load(const TopoDS_Shape& shape,
|
||||
const Standard_Real tol) {
|
||||
PtrJetons=NULL;
|
||||
PtrJetonsIndex=NULL;
|
||||
if(nbfaces) {
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void IntCurvesFace_ShapeIntersector::Load(const TopoDS_Shape& theShape,
|
||||
const Standard_Real theTol)
|
||||
{
|
||||
TopExp_Explorer Ex;
|
||||
Standard_Integer i;
|
||||
for(nbfaces=0,i=0,Ex.Init(shape,TopAbs_FACE); Ex.More(); i++,Ex.Next()) {
|
||||
nbfaces++;
|
||||
TopoDS_Face currentface = TopoDS::Face(Ex.Current());
|
||||
PtrIntersector.Append((void *)(new IntCurvesFace_Intersector(currentface,tol)));
|
||||
}
|
||||
for(myNbFaces = 0, i = 0, Ex.Init(theShape, TopAbs_FACE); Ex.More(); ++i, Ex.Next())
|
||||
{
|
||||
++myNbFaces;
|
||||
TopoDS_Face aCurrentFace = TopoDS::Face(Ex.Current());
|
||||
myIntersector.Append(new IntCurvesFace_Intersector(aCurrentFace, theTol));
|
||||
}
|
||||
}
|
||||
//-- ================================================================================
|
||||
void IntCurvesFace_ShapeIntersector::Destroy() {
|
||||
if(PtrJetons) {
|
||||
delete ((Standard_Integer *)PtrJetons);
|
||||
PtrJetons=NULL;
|
||||
}
|
||||
if(PtrJetonsIndex) {
|
||||
delete ((Standard_Integer *)PtrJetonsIndex);
|
||||
PtrJetonsIndex=NULL;
|
||||
}
|
||||
for(Standard_Integer i=1; i<=nbfaces; i++) {
|
||||
IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
|
||||
delete Ptr;
|
||||
}
|
||||
done=Standard_False;
|
||||
nbfaces=0;
|
||||
PtrIntersector.Clear();
|
||||
IndexPt.Clear(); IndexFace.Clear(); IndexIntPnt.Clear();IndexPar.Clear();
|
||||
}
|
||||
//-- ================================================================================
|
||||
void IntCurvesFace_ShapeIntersector::Perform(const gp_Lin& L,
|
||||
const Standard_Real ParMin,
|
||||
const Standard_Real ParMax) {
|
||||
done = Standard_False;
|
||||
for(Standard_Integer i=1; i<=nbfaces; i++) {
|
||||
IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
|
||||
Ptr->Perform(L,ParMin,ParMax);
|
||||
|
||||
void IntCurvesFace_ShapeIntersector::Perform(const gp_Lin& theL,
|
||||
const Standard_Real theParMin,
|
||||
const Standard_Real theParMax)
|
||||
{
|
||||
myIsDone = Standard_False;
|
||||
for(Standard_Integer i = 1; i <= myNbFaces; ++i)
|
||||
{
|
||||
myIntersector.ChangeValue(i)->Perform(theL, theParMin, theParMax);
|
||||
}
|
||||
SortResult();
|
||||
}
|
||||
//-- ================================================================================
|
||||
void IntCurvesFace_ShapeIntersector::PerformNearest(const gp_Lin& L,
|
||||
const Standard_Real ParMin,
|
||||
const Standard_Real _ParMax) {
|
||||
|
||||
Standard_Integer i;
|
||||
Standard_Integer* _PtrJetons=(Standard_Integer *)PtrJetons;
|
||||
Standard_Integer* _PtrJetonsIndex=(Standard_Integer *)PtrJetonsIndex;
|
||||
|
||||
|
||||
if(nbfaces>2) {
|
||||
if(PtrJetons==NULL) {
|
||||
PtrJetons = (void *) new Standard_Integer [nbfaces];
|
||||
PtrJetonsIndex = (void *) new Standard_Integer [nbfaces];
|
||||
Standard_Integer *Ptr =(Standard_Integer *)PtrJetons;
|
||||
Standard_Integer *PtrI=(Standard_Integer *)PtrJetonsIndex;
|
||||
for(i=0;i<nbfaces;i++) {
|
||||
Ptr[i]=0;
|
||||
PtrI[i]=i+1;
|
||||
}
|
||||
_PtrJetons=(Standard_Integer *)PtrJetons;
|
||||
_PtrJetonsIndex=(Standard_Integer *)PtrJetonsIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Standard_Integer Indexface=-1;
|
||||
Standard_Real ParMax=_ParMax;
|
||||
|
||||
|
||||
done = Standard_False;
|
||||
for(Standard_Integer ii=1; ii<=nbfaces; ii++) {
|
||||
if(_PtrJetons) {
|
||||
i=_PtrJetonsIndex[ii-1];
|
||||
}
|
||||
else {
|
||||
i=ii;
|
||||
}
|
||||
|
||||
IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
|
||||
if(ParMin<ParMax) {
|
||||
Ptr->Perform(L,ParMin,ParMax);
|
||||
if(Ptr->IsDone()) {
|
||||
Standard_Integer n=Ptr->NbPnt();
|
||||
for(Standard_Integer j=1;j<=n;j++) {
|
||||
Standard_Real w=Ptr->WParameter(j);
|
||||
if(w<ParMax) {
|
||||
ParMax=w;
|
||||
Indexface=ii-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
done = Standard_False;
|
||||
return;
|
||||
void IntCurvesFace_ShapeIntersector::PerformNearest(const gp_Lin& theL,
|
||||
const Standard_Real theParMin,
|
||||
const Standard_Real theParMax)
|
||||
{
|
||||
Standard_Integer i = 0;
|
||||
if(myNbFaces > 2)
|
||||
{
|
||||
if (myPtrNums.IsEmpty())
|
||||
{
|
||||
myPtrNums = TColStd_HArray1OfInteger(0, myNbFaces - 1);
|
||||
myPtrIndexNums = TColStd_HArray1OfInteger(0, myNbFaces - 1);
|
||||
for(; i < myNbFaces; ++i)
|
||||
{
|
||||
myPtrNums.ChangeValue(i) = 0;
|
||||
myPtrIndexNums.ChangeValue(i) = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(PtrJetons && Indexface>=0) {
|
||||
_PtrJetons[Indexface]++;
|
||||
|
||||
|
||||
Standard_Integer anIndexFace = -1;
|
||||
Standard_Real aParMax=theParMax;
|
||||
myIsDone = Standard_False;
|
||||
for(Standard_Integer ii = 1; ii <= myNbFaces; ++ii)
|
||||
{
|
||||
if (!myPtrNums.IsEmpty())
|
||||
{
|
||||
i = myPtrIndexNums.Value(ii - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
i = ii;
|
||||
}
|
||||
Handle(IntCurvesFace_Intersector) anIntersector = myIntersector.ChangeValue(i);
|
||||
if(theParMin < aParMax)
|
||||
{
|
||||
anIntersector->Perform(theL, theParMin,aParMax);
|
||||
if(anIntersector->IsDone())
|
||||
{
|
||||
Standard_Integer n = anIntersector->NbPnt();
|
||||
for(Standard_Integer j = 1; j <= n; ++j)
|
||||
{
|
||||
Standard_Real w = anIntersector->WParameter(j);
|
||||
if(w < aParMax)
|
||||
{
|
||||
aParMax = w;
|
||||
anIndexFace = ii - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myIsDone = Standard_False;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!myPtrNums.IsEmpty() && anIndexFace >= 0)
|
||||
{
|
||||
myPtrNums.ChangeValue(anIndexFace) += 1;
|
||||
Standard_Integer im1;
|
||||
for(im1=Indexface-1,i=Indexface; i>=1 && _PtrJetons[i]>_PtrJetons[i-1]; i--,im1--) {
|
||||
Standard_Integer t=_PtrJetonsIndex[i];
|
||||
_PtrJetonsIndex[i]=_PtrJetonsIndex[im1];
|
||||
_PtrJetonsIndex[im1]=t;
|
||||
t=_PtrJetons[i];
|
||||
_PtrJetons[i]=_PtrJetons[im1];
|
||||
_PtrJetons[im1]=t;
|
||||
for (im1 = anIndexFace - 1, i = anIndexFace; i >= 1 && myPtrNums.Value(i) > myPtrNums.Value(im1); --i, --im1)
|
||||
{
|
||||
std::swap(myPtrIndexNums.ChangeValue(i), myPtrIndexNums.ChangeValue(im1));
|
||||
std::swap(myPtrNums.ChangeValue(i), myPtrNums.ChangeValue(im1));
|
||||
}
|
||||
//--for(Standard_Integer dd=0; dd<nbfaces;dd++) { if(_PtrJetons[dd]) { printf("\n<%3d %3d %3d>",dd,_PtrJetons[dd],_PtrJetonsIndex[dd]); } }
|
||||
//--printf("\n");
|
||||
}
|
||||
SortResult();
|
||||
}
|
||||
|
||||
void IntCurvesFace_ShapeIntersector::Perform(const Handle(Adaptor3d_Curve)& theHCurve,
|
||||
const Standard_Real theParMin,
|
||||
const Standard_Real theParMax)
|
||||
{
|
||||
myIsDone = Standard_False;
|
||||
for(Standard_Integer i = 1; i <= myNbFaces; ++i)
|
||||
{
|
||||
Handle(IntCurvesFace_Intersector) anIntersector = myIntersector.ChangeValue(i);
|
||||
anIntersector->Perform(theHCurve, theParMin, theParMax);
|
||||
}
|
||||
SortResult();
|
||||
}
|
||||
//-- ================================================================================
|
||||
void IntCurvesFace_ShapeIntersector::Perform(const Handle(Adaptor3d_Curve)& HCu,
|
||||
const Standard_Real ParMin,
|
||||
const Standard_Real ParMax) {
|
||||
done = Standard_False;
|
||||
for(Standard_Integer i=1; i<=nbfaces; i++) {
|
||||
IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
|
||||
Ptr->Perform(HCu,ParMin,ParMax);
|
||||
}
|
||||
SortResult();
|
||||
}
|
||||
//-- ================================================================================
|
||||
//-- PtrIntersector : Sequence d addresses
|
||||
//-- IndexPt : 1 2 3 .... n points avant le tri
|
||||
//-- IndexFace : Numero de la face (de l intersector) du point IndexPt(i)
|
||||
//-- IndexIntPnt : Numero du point IndexPt(i) dans l'intersector IndexFace(IndexPt(i))
|
||||
//-- IndexPar : W parameter du point IndexPt(i)
|
||||
//-- myIntersector : Sequence of the addresses
|
||||
//-- myIndexPt : 1 2 3 .... n Points before the sorting
|
||||
//-- myNumberFace : Number of the face (of the intersector) of the point myIndexPt(i)
|
||||
//-- myNumberIntPnt : Number of the point myIndexPt(i) of the intersection myNumberFace(myIndexPt(i))
|
||||
//-- myIndexPar : Parameter W of point myIndexPt(i)
|
||||
//--
|
||||
//-- En resume, pour chaque point indice par K = IndexPt(i) on a
|
||||
//-- * la face a laquelle il appartient : IndexFace(K)
|
||||
//-- * le numero du point dans l'intersecteur FaceCurve : IndexIntPnt(K)
|
||||
//-- * le parametre W du point sur la courbe : IndexPar(K)
|
||||
//-- To sum up, for each point index of K = myIndexPt(i) on a
|
||||
//-- * the face to which it belongs : myNumberFace(K)
|
||||
//-- * the number of the point in the intersection for FaceCurve : myNumberIntPnt(K)
|
||||
//-- * the parameter W of the point on the curve : myIndexPar(K)
|
||||
//--
|
||||
//-- SortResult Trie les points par ordre croissant de W
|
||||
//-- (remet a jour le tableau d index TabPt(.))
|
||||
//-- SortResult Sorts the points in ascending order of W
|
||||
//-- (updating the index table TabPt(.))
|
||||
//--
|
||||
//-- ================================================================================
|
||||
void IntCurvesFace_ShapeIntersector::SortResult() {
|
||||
done = Standard_True;
|
||||
Standard_Integer nbpnt=0;
|
||||
IndexPt.Clear(); IndexFace.Clear(); IndexIntPnt.Clear();IndexPar.Clear();
|
||||
//-- -----------------------------------------------------
|
||||
//-- r e c u p e r a t i o n d e s r e s u l t a t s
|
||||
//--
|
||||
for(Standard_Integer f=1; f<=nbfaces; f++) {
|
||||
IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(f);
|
||||
if(Ptr->IsDone()) {
|
||||
Standard_Integer n=Ptr->NbPnt();
|
||||
for(Standard_Integer j=1;j<=n;j++) {
|
||||
IndexPt.Append(++nbpnt);
|
||||
IndexFace.Append(f);
|
||||
IndexIntPnt.Append(j);
|
||||
IndexPar.Append(Ptr->WParameter(j));
|
||||
void IntCurvesFace_ShapeIntersector::SortResult()
|
||||
{
|
||||
myIsDone = Standard_True;
|
||||
Standard_Integer aNbPnt=0;
|
||||
myIndexPt.Clear();
|
||||
myIndexFace.Clear();
|
||||
myIndexIntPnt.Clear();
|
||||
myIndexPar.Clear();
|
||||
|
||||
//Retrieval of the results
|
||||
for(Standard_Integer f = 1; f <= myNbFaces; ++f)
|
||||
{
|
||||
Handle(IntCurvesFace_Intersector) anIntersector = myIntersector.ChangeValue(f);
|
||||
if(anIntersector->IsDone())
|
||||
{
|
||||
Standard_Integer n = anIntersector->NbPnt();
|
||||
for(Standard_Integer j = 1; j <= n; ++j)
|
||||
{
|
||||
myIndexPt.Append(++aNbPnt);
|
||||
myIndexFace.Append(f);
|
||||
myIndexIntPnt.Append(j);
|
||||
myIndexPar.Append(anIntersector->WParameter(j));
|
||||
}
|
||||
}
|
||||
else {
|
||||
done = Standard_False;
|
||||
else
|
||||
{
|
||||
myIsDone = Standard_False;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//-- -----------------------------------------------------
|
||||
//-- t r i s e l o n l e p a r a m e t r e w
|
||||
//--
|
||||
Standard_Boolean triok;
|
||||
do {
|
||||
triok=Standard_True;
|
||||
for(Standard_Integer ind0=1;ind0<nbpnt;ind0++) {
|
||||
Standard_Integer ind =IndexPt(ind0);
|
||||
Standard_Integer indp1=IndexPt(ind0+1);
|
||||
if(IndexPar(ind) > IndexPar(indp1)) {
|
||||
IndexPt(ind0) =indp1;
|
||||
IndexPt(ind0+1)=ind;
|
||||
triok=Standard_False;
|
||||
|
||||
//Sort according to parameter w
|
||||
Standard_Boolean isOK;
|
||||
do
|
||||
{
|
||||
isOK = Standard_True;
|
||||
for(Standard_Integer ind0 = 1; ind0 < aNbPnt; ind0++)
|
||||
{
|
||||
Standard_Integer ind = myIndexPt(ind0);
|
||||
Standard_Integer indp1 = myIndexPt(ind0 + 1);
|
||||
if(myIndexPar(ind) > myIndexPar(indp1))
|
||||
{
|
||||
myIndexPt(ind0) = indp1;
|
||||
myIndexPt(ind0 + 1) = ind;
|
||||
isOK = Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(triok==Standard_False);
|
||||
while(!isOK);
|
||||
}
|
||||
|
||||
IntCurvesFace_ShapeIntersector::~IntCurvesFace_ShapeIntersector()
|
||||
{
|
||||
}
|
||||
//-- ================================================================================
|
||||
//-- Creation le 28 jan 98
|
||||
//--
|
||||
|
@@ -23,12 +23,12 @@
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Address.hxx>
|
||||
#include <BRepTopAdaptor_SeqOfPtr.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <IntCurveSurface_TransitionOnCurve.hxx>
|
||||
#include <IntCurvesFace_Intersector.hxx>
|
||||
#include <TopAbs_State.hxx>
|
||||
|
||||
class Adaptor3d_Curve;
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
//! segment L and the loaded shape.
|
||||
//!
|
||||
//! PInf is the smallest parameter on the line
|
||||
//! PSup is the highest parammter on the line
|
||||
//! PSup is the highest parameter on the line
|
||||
//!
|
||||
//! For an infinite line PInf and PSup can be
|
||||
//! +/- RealLast.
|
||||
@@ -62,92 +62,102 @@ public:
|
||||
//! segment L and the loaded shape.
|
||||
//!
|
||||
//! PInf is the smallest parameter on the line
|
||||
//! PSup is the highest parammter on the line
|
||||
//! PSup is the highest parameter on the line
|
||||
//!
|
||||
//! For an infinite line PInf and PSup can be
|
||||
//! +/- RealLast.
|
||||
Standard_EXPORT void PerformNearest (const gp_Lin& L, const Standard_Real PInf, const Standard_Real PSup);
|
||||
|
||||
//! same method for a HCurve from Adaptor3d.
|
||||
//! PInf an PSup can also be - and + INF.
|
||||
//! PInf an PSup can also be -INF and +INF.
|
||||
Standard_EXPORT void Perform (const Handle(Adaptor3d_Curve)& HCu, const Standard_Real PInf, const Standard_Real PSup);
|
||||
|
||||
//! True is returned when the intersection have been computed.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
Standard_Integer NbPnt() const;
|
||||
//! True when the intersection has been computed.
|
||||
Standard_Boolean IsDone() const
|
||||
{
|
||||
return myIsDone;
|
||||
}
|
||||
//! Returns the number of the intersection points
|
||||
Standard_Integer NbPnt() const
|
||||
{
|
||||
return myIndexPt.Length();
|
||||
}
|
||||
|
||||
//! Returns the U parameter of the ith intersection point
|
||||
//! on the surface.
|
||||
Standard_Real UParameter (const Standard_Integer I) const;
|
||||
|
||||
Standard_Real UParameter (const Standard_Integer I) const
|
||||
{
|
||||
Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
|
||||
return anIntAdaptor->UParameter(myIndexIntPnt(myIndexPt(I)));
|
||||
}
|
||||
|
||||
//! Returns the V parameter of the ith intersection point
|
||||
//! on the surface.
|
||||
Standard_Real VParameter (const Standard_Integer I) const;
|
||||
Standard_Real VParameter (const Standard_Integer I) const
|
||||
{
|
||||
Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
|
||||
return anIntAdaptor->VParameter(myIndexIntPnt(myIndexPt(I)));
|
||||
}
|
||||
|
||||
//! Returns the parameter of the ith intersection point
|
||||
//! on the line.
|
||||
Standard_Real WParameter (const Standard_Integer I) const;
|
||||
Standard_Real WParameter (const Standard_Integer I) const
|
||||
{
|
||||
Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
|
||||
return anIntAdaptor->WParameter(myIndexIntPnt(myIndexPt(I)));
|
||||
}
|
||||
|
||||
//! Returns the geometric point of the ith intersection
|
||||
//! between the line and the surface.
|
||||
const gp_Pnt& Pnt (const Standard_Integer I) const;
|
||||
const gp_Pnt& Pnt (const Standard_Integer I) const
|
||||
{
|
||||
Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
|
||||
return anIntAdaptor->Pnt(myIndexIntPnt(myIndexPt(I)));
|
||||
}
|
||||
|
||||
//! Returns the ith transition of the line on the surface.
|
||||
IntCurveSurface_TransitionOnCurve Transition (const Standard_Integer I) const;
|
||||
IntCurveSurface_TransitionOnCurve Transition (const Standard_Integer I) const
|
||||
{
|
||||
Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
|
||||
return anIntAdaptor->Transition(myIndexIntPnt(myIndexPt(I)));
|
||||
}
|
||||
|
||||
//! Returns the ith state of the point on the face.
|
||||
//! The values can be either TopAbs_IN
|
||||
//! ( the point is in the face)
|
||||
//! or TopAbs_ON
|
||||
//! ( the point is on a boundary of the face).
|
||||
TopAbs_State State (const Standard_Integer I) const;
|
||||
TopAbs_State State(const Standard_Integer I) const
|
||||
{
|
||||
Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
|
||||
return anIntAdaptor->State(myIndexIntPnt(myIndexPt(I)));
|
||||
}
|
||||
|
||||
//! Returns the significant face used to determine
|
||||
//! the intersection.
|
||||
const TopoDS_Face& Face (const Standard_Integer I) const;
|
||||
const TopoDS_Face& Face(const Standard_Integer I) const
|
||||
{
|
||||
Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
|
||||
return anIntAdaptor->Face();
|
||||
}
|
||||
|
||||
//! Internal method. Sort the result on the Curve
|
||||
//! parameter.
|
||||
Standard_EXPORT void SortResult();
|
||||
|
||||
Standard_EXPORT void Destroy();
|
||||
~IntCurvesFace_ShapeIntersector()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
Standard_EXPORT virtual ~IntCurvesFace_ShapeIntersector();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean done;
|
||||
Standard_Integer nbfaces;
|
||||
Standard_Address PtrJetons;
|
||||
Standard_Address PtrJetonsIndex;
|
||||
BRepTopAdaptor_SeqOfPtr PtrIntersector;
|
||||
TColStd_SequenceOfInteger IndexPt;
|
||||
TColStd_SequenceOfInteger IndexFace;
|
||||
TColStd_SequenceOfInteger IndexIntPnt;
|
||||
TColStd_SequenceOfReal IndexPar;
|
||||
|
||||
|
||||
|
||||
Standard_Boolean myIsDone;
|
||||
Standard_Integer myNbFaces;
|
||||
TColStd_Array1OfInteger myPtrNums;
|
||||
TColStd_Array1OfInteger myPtrIndexNums;
|
||||
NCollection_Sequence<Handle(IntCurvesFace_Intersector)> myIntersector;
|
||||
TColStd_SequenceOfInteger myIndexPt;
|
||||
TColStd_SequenceOfInteger myIndexFace;
|
||||
TColStd_SequenceOfInteger myIndexIntPnt;
|
||||
TColStd_SequenceOfReal myIndexPar;
|
||||
};
|
||||
|
||||
|
||||
#include <IntCurvesFace_ShapeIntersector.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _IntCurvesFace_ShapeIntersector_HeaderFile
|
||||
|
@@ -1,71 +0,0 @@
|
||||
// Created on: 1998-01-28
|
||||
// Created by: Laurent BUCHARD
|
||||
// Copyright (c) 1998-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <IntCurvesFace_Intersector.hxx>
|
||||
|
||||
|
||||
inline Standard_Integer IntCurvesFace_ShapeIntersector::NbPnt() const {
|
||||
return(IndexPt.Length());
|
||||
}
|
||||
|
||||
inline Standard_Real IntCurvesFace_ShapeIntersector::UParameter(const Standard_Integer i) const {
|
||||
IntCurvesFace_Intersector *Ptr =
|
||||
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
|
||||
return(Ptr->UParameter(IndexIntPnt(IndexPt(i))));
|
||||
}
|
||||
|
||||
inline Standard_Real IntCurvesFace_ShapeIntersector::VParameter(const Standard_Integer i) const {
|
||||
IntCurvesFace_Intersector *Ptr =
|
||||
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
|
||||
return(Ptr->VParameter(IndexIntPnt(IndexPt(i))));
|
||||
}
|
||||
|
||||
inline Standard_Real IntCurvesFace_ShapeIntersector::WParameter(const Standard_Integer i) const {
|
||||
IntCurvesFace_Intersector *Ptr =
|
||||
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
|
||||
return(Ptr->WParameter(IndexIntPnt(IndexPt(i))));
|
||||
}
|
||||
|
||||
inline const gp_Pnt& IntCurvesFace_ShapeIntersector::Pnt(const Standard_Integer i) const {
|
||||
IntCurvesFace_Intersector *Ptr =
|
||||
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
|
||||
return(Ptr->Pnt(IndexIntPnt(IndexPt(i))));
|
||||
}
|
||||
|
||||
inline IntCurveSurface_TransitionOnCurve IntCurvesFace_ShapeIntersector::Transition(const Standard_Integer i) const {
|
||||
IntCurvesFace_Intersector *Ptr =
|
||||
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
|
||||
return(Ptr->Transition(IndexIntPnt(IndexPt(i))));
|
||||
}
|
||||
|
||||
inline TopAbs_State IntCurvesFace_ShapeIntersector::State(const Standard_Integer i) const {
|
||||
IntCurvesFace_Intersector *Ptr =
|
||||
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
|
||||
return(Ptr->State(IndexIntPnt(IndexPt(i))));
|
||||
}
|
||||
|
||||
|
||||
inline const TopoDS_Face& IntCurvesFace_ShapeIntersector::Face(const Standard_Integer i) const {
|
||||
IntCurvesFace_Intersector *Ptr =
|
||||
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
|
||||
return(Ptr->Face());
|
||||
}
|
||||
|
||||
inline Standard_Boolean IntCurvesFace_ShapeIntersector::IsDone() const {
|
||||
return(done);
|
||||
}
|
||||
|
||||
|
@@ -433,10 +433,32 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
|
||||
if(aStep < Epsilon(theLPar))
|
||||
break;
|
||||
|
||||
Standard_Boolean isStepReduced = Standard_False;
|
||||
Standard_Real aLPar = theLPar;
|
||||
|
||||
for (Standard_Integer i = aVertexParams.Lower(); i <= aVertexParams.Upper(); i++)
|
||||
{
|
||||
if (hasVertexBeenChecked(i))
|
||||
continue;
|
||||
|
||||
aLPar = aVertexParams(i);
|
||||
if (Abs(aLPar - aParameter) < aPrmTol)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ((aStep - (aLPar - aParameter) > aPrmTol) &&
|
||||
(Abs(aLPar - aParameter) > aPrmTol))
|
||||
{
|
||||
aStep = Max((aLPar - aParameter) / 5, 1.e-5);
|
||||
isStepReduced = Standard_True;
|
||||
}
|
||||
|
||||
Standard_Integer aNewVertID = 0;
|
||||
aLinOn2S = new IntSurf_LineOn2S;
|
||||
|
||||
const Standard_Real aStepMin = 0.1*aStep, aStepMax = 10.0*aStep;
|
||||
Standard_Real aStepMin = 0.1 * aStep, aStepMax = 10.0 * aStep;
|
||||
|
||||
Standard_Boolean isLast = Standard_False;
|
||||
Standard_Real aPrevParam = aParameter;
|
||||
@@ -586,8 +608,12 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
|
||||
{
|
||||
if (isPointValid)
|
||||
{
|
||||
StepComputing(theALine, aPOn2S, theLPar, aParameter, aTgMagn,
|
||||
aStepMin, aStepMax, myTol3D, aStep);
|
||||
if (!isStepReduced)
|
||||
{
|
||||
StepComputing(theALine, aPOn2S, theLPar, aParameter, aTgMagn,
|
||||
aStepMin, aStepMax, myTol3D, aStep);
|
||||
}
|
||||
|
||||
AddPointIntoLine(aLinOn2S, anArrPeriods, aPOn2S);
|
||||
aPrevLPoint = aPOn2S;
|
||||
}
|
||||
@@ -694,6 +720,38 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
|
||||
|
||||
if ((aPrePointExist != IntPatch_SPntNone) && (aLinOn2S->NbPoints() > 1))
|
||||
break;
|
||||
|
||||
if (isStepReduced)
|
||||
{
|
||||
isStepReduced = Standard_False;
|
||||
|
||||
aStep = (theLPar - aParameter) / (Standard_Real)(myNbPointsInWline - 1);
|
||||
if(aStep < Epsilon(theLPar))
|
||||
break;
|
||||
|
||||
aLPar = aVertexParams(aNbVert);
|
||||
for (Standard_Integer i = aVertexParams.Lower(); i <= aVertexParams.Upper(); i++)
|
||||
{
|
||||
if (hasVertexBeenChecked(i))
|
||||
continue;
|
||||
|
||||
aLPar = aVertexParams(i);
|
||||
if (Abs(aLPar - aParameter) < aPrmTol)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ((aStep - (aLPar - aParameter) > aPrmTol) &&
|
||||
(Abs(aLPar - aParameter) > aPrmTol))
|
||||
{
|
||||
aStep = Max((aLPar - aParameter) / 5, 1.e-5);
|
||||
isStepReduced = Standard_True;
|
||||
}
|
||||
|
||||
aStepMin = 0.1 * aStep;
|
||||
aStepMax = 10.0 * aStep;
|
||||
}
|
||||
}//for(; !isLast; aParameter += aStep)
|
||||
|
||||
if(aLinOn2S->NbPoints() < 2)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user