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

Compare commits

..

30 Commits

Author SHA1 Message Date
kgv
35a381fd03 0030602: Tests - testdiff does not report known unstable cases properly
Comment TODOs
2019-03-25 09:07:02 +03:00
emv
d84b49c743 0030522: Modeling Algorithms - BRepBuilderAPI_MakeWire produces different wires depending on the order of parameters
The following improvements have been implemented in BRepLib_MakeWire class to make it more reliable:
1. Quit adding edges of a wire into result if the current edges have not been added. Return NotDone status.
2. Allow merging not only bounding vertices (connected to only one edge) but also the middle ones, so the multi-connected vertices may appear in the result.

Test case for the issue.
2019-03-22 17:21:01 +03:00
kgv
aff73fd598 0030582: Coding - avoid defining references to properties of NULL objects
Approx_SweepApproximation::Perform() now creates empty arrays.
GeomAdaptor_SurfaceOfRevolution::UTrim() - fixed No_Exception misuse.
StdPrs_ShadedShape - fixed defining an invalid reference to Poly_Triangulation::UVNodes().

BSplCLib::MovePoint() and BSplCLib::MovePointAndTangent() now take optional
weights parameter as pointer consistent to other methods like BSplCLib::BuildEval().
2019-03-22 17:21:01 +03:00
ifv
afb3647b34 0030489: Modeling Algorithms - BRepBuilderAPI_GTransform hangs
Approx_ComputeCLine.gxx - criterium to stop interval cutting is increased.
ProjLib_ProjectedCurve.cxx - fix regression for bugs modalg_5 bug25886
Other tests are modified according to current state of algorithm
2019-03-22 17:21:00 +03:00
kgv
2328cae25d 0030593: Modeling Algorithms - ShapeUpgrade_ShapeDivide::Perform() throws Standard_NoMoreObject
Added missing TopExp_Explorer::More() checks to ShapeUpgrade_ShapeDivide::Perform() and BRepCheck_Analyzer::Perform().
2019-03-21 13:16:11 +03:00
kgv
85831628d6 0027316: Draw Harness - access violation on passing non-existing shape to XAddShape
Add NULL check to XAddShape command.
Removed broken test case bugs/step/bug27316.
2019-03-21 13:15:15 +03:00
kgv
667b5eb81b 0030583: Draw Harness - ignore cpulimit when Debugger is attached on Windows platform
cpulimit now omits ExitProcess() when IsDebuggerPresent() returns TRUE.
2019-03-20 19:00:48 +03:00
kgv
de07af824b 0030594: Data Exchange - access violation within IGESGeom_BSplineCurve constructor
Added NULL check.
2019-03-20 18:11:41 +03:00
kgv
cb6cad7df1 0023838: Modeling Data - Standard_OutOfRange in Geom_OffsetSurface::LocalDN (called by BRepFill_PipeShell)
Fixed incorrect array allocation within GeomEvaluator_OffsetSurface::CalculateDN()
and protection against assigning out-of-range values in case of non-square
number of U and V derivatives on surface.
2019-03-20 11:25:06 +03:00
kgv
ad67e36766 0030588: Coding - avoid calling operator->() on NULL Handle
Use .get() method instead of operator->() where result can be NULL.
STEPCAFControl_Reader::ReadLayers(), XCAFDoc_ColorTool,
XCAFDoc_LayerTool::SetVisibility() - fixed static functions syntax.
2019-03-20 11:23:45 +03:00
kgv
18434846a3 0030558: Coding - replace math_SingleTab with NCollection_LocalArray
math_Vector::Multiplied() - fixed modification of original array.

math_SVD::Solve(), math_SVD::PseudoInverse(), GeomFill_LocationGuide::InitX() - removed incorrect constness.

math_Vector, math_IntegerVector - math_SingleTab has been replaced by NCollection_LocalArray+NCollection_Array1.
Added accessors returning const value.
2019-03-20 11:23:08 +03:00
vro
43c8661e5e 0030536: Foundation Classes - TCollection_ExtendedString::StartsWith() and EndsWith() have a mistake
Draw-commands StartsWith and EndsWith are renamed to QAStartsWith and QAEndsWith.
The test script bug30536 was corrected.
2019-03-18 19:46:00 +03:00
abv
404504b234 0030544: Data Exchange - IGES import fails on specific file
Method IGESToBRep_BRepEntity::TransferEdge() is fixed to record result even if it is wire rather than edge.
This allows translation of EdgeLoop entities referring to CompositeCurve items in EdgeList entities.
Curves that fail to translate are recorded in result as Null shapes (rather than skipping them) to keep indexation of curves in EdgeList valid for remaining ones.

Method IGESToBRep_BRepEntity::TransferLoop() is improved to skip failed edges thus avoiding exception and allowing translation to complete for transferable entities.

Warning messages are corrected to be more meaningful.
Added test bugs iges bug30544
2019-03-18 19:45:07 +03:00
kgv
d65f9183fd 0030569: Foundation Classes - NCollection_Shared lacks inclusion of NCollection_DefineAlloc.hxx
Add missing includes.
2019-03-18 19:43:55 +03:00
kgv
6b121e2b48 0030584: Modeling Algorithms, BRepFill_OffsetWire - access violation on Face having no boundaries
Added missing NULL and empty result checks.
Updated test cases using offset_wire_092.brep shape containing all Edges
with TopAbs_INTERNAL orientation (hense no boundary to make offset).
2019-03-18 19:42:47 +03:00
kgv
437ef7713e 0030581: Modeling Data - Standard_OutOfRange within Geom_BSplineSurface::LocateV()
Geom2d_BSplineCurve::LocateU(),Geom_BSplineCurve::LocateU, Law_BSpline::LocateU()
Geom_BSplineSurface::LocateU() and Geom_BSplineSurface::LocateV()
have been corrected with missing range checks.
BSplCLib::Hunt() documentation has been corrected to reflect its actual implementation.
2019-03-18 19:41:40 +03:00
kgv
737e9a8da4 0030571: Visualization, TKOpenGl - mapped texture is ignored while drawing points
OpenGl_AspectsTextureSet now appends Sprite texture to the end of texture set.
OpenGl_Context::init() - fixed usage of GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS on too old GL context.

Default sampler names occSampler0, occActiveSampler and occSamplerBaseColor
are now excluded from header with common declarations for build-in GLSL programs.

OpenGl_ShaderObject::LoadAndCompile() and OpenGl_ShaderProgram::Link()
now includes program Id within error log.

OpenGl_ShaderManager now supports mapping texture onto point primitive within built-in programs
(texture transformation is ignored).
2019-03-16 16:48:21 +03:00
oan
ad4b04291f 0030511: Mesh - too long meshing of assembly containing single solid (shared)
Added test case.
2019-03-16 16:46:53 +03:00
oan
e9fb0cba58 0030573: OSD_Parallel_TBB: limit number of execution threads using settings of OSD_ThreadPool::DefaultPool()
Add tbb::task_scheduler_init to OSD_Parallel::forEach().
2019-03-16 16:46:53 +03:00
kgv
f2b42160f4 0030575: Tests - v3d/materials unstable image screenshots of alpha-blending on GeForce with MSAA
testdiff now looks for "IMAGE_COLOR_TOLERANCE: Tol" statements in log
to execute diffimage with -toleranceOfColor Tol parameter.

Image difference is first performed with 0 tolerance and then optionally with non-zero tolerance,
so that the log always includes information that some images are different,
but with two different messages:
- "IMAGE differs" for images failed comparison;
- "IMAGE is similar" for images passed comparison only with non-zero tolerance.

v3d/materials - disabled MSAA and removed duplicate.
demo/samples/materials - compare screenshots with 0.8% color tolerance (2/255).
2019-03-16 16:46:52 +03:00
kgv
6072d5975a 0030580: Configuration, CMake - introduce BUILD_RELEASE_DISABLE_EXCEPTIONS option managing No_Exception macros 2019-03-16 16:46:51 +03:00
jgv
85c103d277 0030560: Modeling Algorithms - Improvement of the method BRepTools::DetectClosedness
1. Rewrite the method BRepTools::DetectClosedness.
2. Correct the method BRepOffset_Tool::EnLargeFace to process properly non-periodic but closed faces.
2019-03-16 16:46:50 +03:00
kgv
31fe1f8ec4 0030570: Visualization, TKOpenGl - OpenGl_AspectFace ignores texture revision on recompute
Added revision check to one more branch within OpenGl_AspectsTextureSet::build().
2019-03-15 19:11:45 +03:00
kgv
5716d13b43 0030564: Coding - math_Gauss uninitialized 'Singular' member variable
Removed unused class field Singular.
2019-03-13 16:39:43 +03:00
kgv
a7fd4b1bb0 0030562: Coding - TopOpeBRepBuild_Builder use of null pointer
TopOpeBRepBuild_Builder::Clear() - added NULL check.
2019-03-13 16:39:41 +03:00
mnv
226fce20f0 0030124: Visualization, AIS_InteractiveObject - clean up confusing Presentation invalidation logic
Removed excess mechanism for invalidating presentations AIS_InteractiveObject::myRecomputeEveryPrs.
PrsMgr_PresentableObject::Update() has been deprecated and replaced by PrsMgr_PresentableObject::UpdatePresentations()
recomputing only explicitly invalidated presentations.
2019-03-13 16:39:40 +03:00
kgv
ac8f17746b 0030554: Coding - ChFiDS_CommonPoint uninitialized member traarc
Added missing initialization to ChFiDS_CommonPoint constructor.
2019-03-13 11:00:23 +03:00
kgv
a98b97f5da 0030553: Coding - TopOpeBRepDS_Surface missing default initalizations
All class fields are now initialized within every TopOpeBRepDS_Surface constructor.
2019-03-13 11:00:22 +03:00
kgv
c3c2b331cd 0030545: Documentation - methods marked with Standard_DEPRECATED has ill-formed Doxygen output
Doxygen option PREDEFINED has been extended by Standard_DEPRECATED declaration.
2019-03-13 11:00:22 +03:00
kgv
af2fa459f1 0030547: Foundation Classes - NCollection_DoubleMap lacks Seek() method
Added Seek1() and Seek2() methods to NCollection_DoubleMap class.
2019-03-13 11:00:21 +03:00
174 changed files with 2402 additions and 3008 deletions

View File

@@ -86,6 +86,11 @@ if (BUILD_WITH_DEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:DEBUG>:OCCT_DEBUG>)
endif()
# option disabling OCCT exceptions in Release builds (No_Exception)
if (NOT DEFINED BUILD_RELEASE_DISABLE_EXCEPTIONS)
set (BUILD_RELEASE_DISABLE_EXCEPTIONS ON CACHE BOOL "${BUILD_RELEASE_DISABLE_EXCEPTIONS_DESCR}")
endif()
# option to enable or disable use of precompiled headers
if (NOT DEFINED BUILD_USE_PCH)
set (BUILD_USE_PCH OFF CACHE BOOL "${BUILD_USE_PCH_DESCR}")

View File

@@ -143,5 +143,7 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR MINGW)
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
endif()
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")
if (BUILD_RELEASE_DISABLE_EXCEPTIONS)
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")
endif()

View File

@@ -28,6 +28,11 @@ Applies only for Debug configuration.")
set (BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR
"Append the postfix to names of output libraries")
set (BUILD_RELEASE_DISABLE_EXCEPTIONS_DESCR
"Disables exceptions like Standard_OutOfRange in Release builds.
Defines No_Exception macros for Release builds when enabled (default).
These exceptions are always enabled in Debug builds, but disable in Release for better performance")
set (BUILD_ENABLE_FPE_SIGNAL_HANDLER_DESCR
"Enable/Disable the floating point exceptions (FPE) during DRAW execution only.
Corresponding environment variable (CSF_FPE) can be changed manually

View File

@@ -1716,6 +1716,21 @@ aGroup->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< next array
aGroup->AddPrimitiveArray (aLines);
~~~~
@subsection upgrade_740_prsupdate Presentation invalidation
Historically AIS_InteractiveObject provided two independent mechanisms invalidating presentation (asking presentation manager to recompute specific display mode or all modes):
1. *AIS_InteractiveObject::SetToUpdate()*, marking existing presentation for update.
This is main invalidation API, which is expected to be followed by *AIS_InteractiveContext::Update()* call.
2. *AIS_InteractiveObject::myToRecomputeModes* + *myRecomputeEveryPrs*.
This is auxiliary invalidation API, used internally by AIS_InteractiveContext::SetColor()/UnsetColor() and similar modification methods.
The latter one has been removed to avoid confusion and unexpected behavior.
In addition, two methods *AIS_InteractiveObject::Update()* have been deprecated in favor of new *AIS_InteractiveObject::UpdatePresentations()* recomputing only invalidated presentations.
Custom presentations implementing interface methods *AIS_InteractiveObject::SetColor()* and others should be revised to use *AIS_InteractiveObject::SetToUpdate()*
or updating presentation without recomputation (see *AIS_InteractiveObject::SynchronizeAspects()* and *AIS_InteractiveObject::replaceAspects()*).
@subsection upgrade_740_interiorstyles Interior styles
* *Aspect_IS_HOLLOW* is now an alias to *Aspect_IS_EMPTY* and does not implicitly enables drawing mesh edges anymore.

View File

@@ -23,7 +23,7 @@ WARNINGS = NO
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
PREDEFINED = Standard_EXPORT Standard_NODISCARD Standard_OVERRIDE:=override __Standard_API __Draw_API Handle(a):=Handle<a> DEFINE_STANDARD_ALLOC DEFINE_NCOLLECTION_ALLOC
PREDEFINED = Standard_EXPORT Standard_NODISCARD Standard_OVERRIDE:=override __Standard_API __Draw_API Handle(a):=Handle<a> DEFINE_STANDARD_ALLOC DEFINE_NCOLLECTION_ALLOC "Standard_DEPRECATED=//! @deprecated "
GENERATE_HTML = YES
GENERATE_LATEX = NO
SEARCH_INCLUDES = YES

View File

@@ -17,7 +17,8 @@ void ISession2D_Shape::Add(const TopoDS_Shape& aShape)
myListOfShape.Append(aShape);
myAlgo.Nullify();
myPolyAlgo.Nullify();
Update(); // protected method used to specify that the presentation are not up to date
SetToUpdate();
UpdatePresentations();
}
void ISession2D_Shape::Remove (const TopoDS_Shape& theShape)
@@ -42,23 +43,17 @@ void ISession2D_Shape::SetProjector (HLRAlgo_Projector& aProjector)
myProjector= aProjector;
myAlgo.Nullify();
myPolyAlgo.Nullify();
Update(); // protected method used to specify that the presentation are not up to date
SetToUpdate();
UpdatePresentations();
};
void ISession2D_Shape::SetNbIsos(Standard_Integer& aNbIsos)
{
myNbIsos= aNbIsos;
myAlgo.Nullify();
// declare the mode 100 to 110 as non valid
for (int i=100;i<=110;i++)
Update(i,Standard_False); // protected method used to specify that the presentation are not up to date
// declare the mode 1100 to 1110 as non valid
for (int i=1100;i<=1110;i++)
Update(i,Standard_False); // protected method used to specify that the presentation are not up to date
{
myNbIsos= aNbIsos;
myAlgo.Nullify();
SetToUpdate();
UpdatePresentations();
};
void ISession2D_Shape::BuildAlgo()

View File

@@ -51,7 +51,7 @@ proc drawObjects {theRow theColor} {
uplevel #0 box $aBox $aCtr $aCtr $aCtr $aSize $aSize $aSize
uplevel #0 ttranslate $aSph $x $y 0
uplevel #0 ttranslate $aBox [expr $x + 10] $y 0
uplevel #0 vdisplay -noredraw $aSph $aBox
uplevel #0 vdisplay -noredraw -dispMode 1 $aSph $aBox
uplevel #0 vsetmaterial -noredraw $aSph $aBox $aMatIter
if {$theColor != ""} {
uplevel #0 vsetcolor -noredraw $aSph $aBox $theColor
@@ -64,21 +64,19 @@ proc drawObjects {theRow theColor} {
# setup 3D viewer content
pload MODELING VISUALIZATION
catch { vclose View1 }
vinit View1 w=768 h=768
vclear
vclose ALL
vinit View1 w=768 h=768
vtop
vglinfo
vsetgradientbg 180 200 255 180 180 180 2
vlight -change 0 -dir 0.577 -0.577 -0.577
vsetdispmode 1
vrenderparams -msaa 8
# adjust scene bounding box
box bnd 0 0 0 180 210 1
vdisplay -noredraw bnd
vsetdispmode bnd 0
vdisplay -noredraw -dispMode 0 bnd
vfit
vremove -noredraw bnd
@@ -88,5 +86,3 @@ drawObjects 0 ""
drawObjects 1 red
drawObjects 2 green
drawObjects 3 blue1
#vfit
vzfit

View File

@@ -221,7 +221,7 @@ void AIS_Axis::SetColor(const Quantity_Color &aCol)
DA->LineAspect(Prs3d_DP_XAxis)->SetColor(aCol);
DA->LineAspect(Prs3d_DP_YAxis)->SetColor(aCol);
DA->LineAspect(Prs3d_DP_ZAxis)->SetColor(aCol);
SynchronizeAspects();
}
//=======================================================================
@@ -230,7 +230,6 @@ void AIS_Axis::SetColor(const Quantity_Color &aCol)
//=======================================================================
void AIS_Axis::SetWidth(const Standard_Real aValue)
{
if(aValue<0.0) return;
if(aValue==0) UnsetWidth();
@@ -240,6 +239,7 @@ void AIS_Axis::SetWidth(const Standard_Real aValue)
DA->LineAspect(Prs3d_DP_XAxis)->SetWidth(aValue);
DA->LineAspect(Prs3d_DP_YAxis)->SetWidth(aValue);
DA->LineAspect(Prs3d_DP_ZAxis)->SetWidth(aValue);
SynchronizeAspects();
}
@@ -324,14 +324,13 @@ AcceptDisplayMode(const Standard_Integer aMode) const
//=======================================================================
void AIS_Axis::UnsetColor()
{
myDrawer->LineAspect()->SetColor(Quantity_NOC_RED);
hasOwnColor=Standard_False;
hasOwnColor = Standard_False;
myDrawer->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetColor(Quantity_NOC_TURQUOISE);
myDrawer->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetColor(Quantity_NOC_TURQUOISE);
myDrawer->DatumAspect()->LineAspect(Prs3d_DP_ZAxis)->SetColor(Quantity_NOC_TURQUOISE);
SynchronizeAspects();
}
//=======================================================================
//function : UnsetWidth
@@ -340,10 +339,10 @@ void AIS_Axis::UnsetColor()
void AIS_Axis::UnsetWidth()
{
myOwnWidth = 0.0;
myOwnWidth = 0.0f;
myDrawer->LineAspect()->SetWidth(1.);
myDrawer->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetWidth(1.);
myDrawer->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetWidth(1.);
myDrawer->DatumAspect()->LineAspect(Prs3d_DP_ZAxis)->SetWidth(1.);
SynchronizeAspects();
}

View File

@@ -90,6 +90,7 @@ void AIS_CameraFrustum::SetColor (const Quantity_Color& theColor)
AIS_InteractiveObject::SetColor (theColor);
myDrawer->ShadingAspect()->SetColor (theColor);
myDrawer->LineAspect()->SetColor (theColor);
SynchronizeAspects();
}
//=======================================================================
@@ -107,6 +108,7 @@ void AIS_CameraFrustum::UnsetColor()
myDrawer->ShadingAspect()->SetColor (THE_DEFAULT_COLOR);
myDrawer->LineAspect()->SetColor (THE_DEFAULT_COLOR);
SynchronizeAspects();
}
//=======================================================================
@@ -117,6 +119,7 @@ void AIS_CameraFrustum::UnsetTransparency()
{
myDrawer->ShadingAspect()->SetTransparency (0.0f);
myDrawer->SetTransparency (0.0f);
SynchronizeAspects();
}
//=======================================================================

View File

@@ -112,6 +112,29 @@ void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
}
//=======================================================================
//function : replaceWithNewLineAspect
//purpose :
//=======================================================================
void AIS_Circle::replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
{
if (!myDrawer->HasLink())
{
myDrawer->SetLineAspect (theAspect);
return;
}
const Handle(Graphic3d_AspectLine3d) anAspectOld = myDrawer->LineAspect()->Aspect();
const Handle(Graphic3d_AspectLine3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
if (anAspectNew != anAspectOld)
{
myDrawer->SetLineAspect (theAspect);
Graphic3d_MapOfAspectsToAspects aReplaceMap;
aReplaceMap.Bind (anAspectOld, anAspectNew);
replaceAspects (aReplaceMap);
}
}
//=======================================================================
//function : SetColor
//purpose :
@@ -122,34 +145,41 @@ void AIS_Circle::SetColor(const Quantity_Color &aCol)
hasOwnColor=Standard_True;
myDrawer->SetColor (aCol);
Standard_Real WW = HasWidth() ? myOwnWidth :
myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) :
1.;
if (!myDrawer->HasOwnLineAspect ())
myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
if (!myDrawer->HasOwnLineAspect())
{
Standard_Real WW = HasWidth() ? myOwnWidth :
myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) :
1.;
replaceWithNewLineAspect (new Prs3d_LineAspect (aCol, Aspect_TOL_SOLID, WW));
}
else
{
myDrawer->LineAspect()->SetColor(aCol);
SynchronizeAspects();
}
}
//=======================================================================
//function : SetWidth
//purpose :
//=======================================================================
void AIS_Circle::SetWidth(const Standard_Real aValue)
{
myOwnWidth=aValue;
myOwnWidth = (Standard_ShortReal )aValue;
if (!myDrawer->HasOwnLineAspect ()) {
if (!myDrawer->HasOwnLineAspect())
{
Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myDrawer->Color();
else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue));
} else
replaceWithNewLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue));
}
else
{
myDrawer->LineAspect()->SetWidth(aValue);
SynchronizeAspects();
}
}
@@ -161,15 +191,18 @@ void AIS_Circle::UnsetColor()
{
hasOwnColor = Standard_False;
Handle(Prs3d_LineAspect) NullAsp;
if (!HasWidth()) myDrawer->SetLineAspect(NullAsp);
else{
if (!HasWidth())
{
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)());
}
else
{
Quantity_Color CC = Quantity_NOC_YELLOW;;
if( HasColor() ) CC = myDrawer->Color();
else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
myDrawer->LineAspect()->SetColor(CC);
myDrawer->SetColor (CC);
SynchronizeAspects();
}
}
@@ -179,11 +212,13 @@ void AIS_Circle::UnsetColor()
//=======================================================================
void AIS_Circle::UnsetWidth()
{
Handle(Prs3d_LineAspect) NullAsp;
if (!HasColor()) myDrawer->SetLineAspect(NullAsp);
else{
Standard_Real WW = myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.;
if (!HasColor())
{
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)());
}
else
{
Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.0f;
myDrawer->LineAspect()->SetWidth(WW);
myOwnWidth = WW;
}

View File

@@ -115,6 +115,9 @@ private:
Standard_EXPORT void ComputeArcSelection (const Handle(SelectMgr_Selection)& aSelection);
//! Replace aspects of already computed groups with the new value.
void replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect);
private:
Handle(Geom_Circle) myComponent;

View File

@@ -124,8 +124,7 @@ Handle(AIS_ColoredDrawer) AIS_ColoredShape::CustomAspects (const TopoDS_Shape& t
{
aDrawer = new AIS_ColoredDrawer (myDrawer);
myShapeColors.Bind (theShape, aDrawer);
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
SetToUpdate();
}
return aDrawer;
}
@@ -141,8 +140,7 @@ void AIS_ColoredShape::ClearCustomAspects()
return;
}
myShapeColors.Clear();
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
SetToUpdate();
}
//=======================================================================
@@ -157,8 +155,7 @@ void AIS_ColoredShape::UnsetCustomAspects (const TopoDS_Shape& theShape,
return;
}
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
SetToUpdate();
if (theToUnregister)
{
myShapeColors.UnBind (theShape);
@@ -183,8 +180,6 @@ void AIS_ColoredShape::SetCustomColor (const TopoDS_Shape& theShape,
const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
setColor (aDrawer, theColor);
aDrawer->SetOwnColor (theColor);
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
}
//=======================================================================
@@ -202,8 +197,6 @@ void AIS_ColoredShape::SetCustomTransparency (const TopoDS_Shape& theShape,
const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
setTransparency (aDrawer, theTransparency);
aDrawer->SetOwnTransparency (theTransparency);
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
}
//=======================================================================
@@ -221,8 +214,6 @@ void AIS_ColoredShape::SetCustomWidth (const TopoDS_Shape& theShape,
const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
setWidth (aDrawer, theLineWidth);
aDrawer->SetOwnWidth (theLineWidth);
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
}
//=======================================================================

View File

@@ -952,7 +952,8 @@ void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObjec
return;
}
theIObj->Update (theAllModes);
theIObj->SetToUpdate();
theIObj->UpdatePresentations (theAllModes);
if (!theToUpdateViewer)
{
return;
@@ -1006,13 +1007,7 @@ void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIOb
return;
}
TColStd_ListOfInteger aPrsModes;
theIObj->ToBeUpdated (aPrsModes);
for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next())
{
theIObj->Update (aPrsModesIt.Value(), Standard_False);
}
theIObj->UpdatePresentations();
mgrSelector->Update(theIObj);
if (theUpdateViewer)
@@ -1369,63 +1364,6 @@ void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_Interactive
}
}
//=======================================================================
//function : redisplayPrsRecModes
//purpose :
//=======================================================================
void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Boolean theToUpdateViewer)
{
if (theIObj->RecomputeEveryPrs())
{
theIObj->Update (Standard_True);
theIObj->UpdateSelection();
}
else
{
for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next())
{
theIObj->Update (aModes.Value(), Standard_False);
}
theIObj->UpdateSelection();
theIObj->SetRecomputeOk();
}
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
//function : redisplayPrsModes
//purpose :
//=======================================================================
void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Boolean theToUpdateViewer)
{
if (theIObj->RecomputeEveryPrs())
{
theIObj->Update (Standard_True);
theIObj->UpdateSelection();
}
else
{
TColStd_ListOfInteger aModes;
theIObj->ToBeUpdated (aModes);
for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next())
{
theIObj->Update (aModeIter.Value(), Standard_False);
}
theIObj->SetRecomputeOk();
}
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
//function : SetColor
//purpose :
@@ -1441,7 +1379,11 @@ void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theI
setContextToObject (theIObj);
theIObj->SetColor (theColor);
redisplayPrsRecModes (theIObj, theToUpdateViewer);
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1486,7 +1428,11 @@ void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_Interacti
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
aShape->SetOwnDeviationCoefficient (theCoefficient);
redisplayPrsModes (theIObj, theToUpdateViewer);
aShape->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1516,7 +1462,11 @@ void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_Intera
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
aShape->SetOwnHLRDeviationCoefficient (theCoefficient);
redisplayPrsModes (theIObj, theToUpdateViewer);
aShape->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1545,7 +1495,11 @@ void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObje
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
aShape->SetOwnDeviationAngle (theAngle);
redisplayPrsModes (theIObj, theToUpdateViewer);
aShape->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1574,15 +1528,10 @@ void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveO
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
aShape->SetAngleAndDeviation (theAngle);
if (theIObj->RecomputeEveryPrs())
aShape->UpdatePresentations();
if (theToUpdateViewer)
{
theIObj->Update (Standard_True);
theIObj->UpdateSelection();
}
else
{
Update (theIObj, theToUpdateViewer);
UpdateCurrentViewer();
}
}
@@ -1611,7 +1560,11 @@ void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_Interacti
}
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
aShape->SetHLRAngleAndDeviation (theAngle);
redisplayPrsModes (theIObj, theToUpdateViewer);
aShape->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1639,7 +1592,11 @@ void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveO
}
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
aShape->SetOwnHLRDeviationAngle (theAngle);
redisplayPrsModes (theIObj, theToUpdateViewer);
aShape->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1655,7 +1612,11 @@ void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& th
}
theIObj->UnsetColor();
redisplayPrsRecModes (theIObj, theToUpdateViewer);
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1701,7 +1662,7 @@ void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theI
setContextToObject (theIObj);
theIObj->SetWidth (theWidth);
redisplayPrsRecModes (theIObj, theToUpdateViewer);
theIObj->UpdatePresentations();
if (!myLastinMain.IsNull() && myLastinMain->IsSameSelectable (theIObj))
{
if (myLastinMain->IsAutoHilight())
@@ -1718,6 +1679,10 @@ void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theI
myLastinMain);
}
}
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1733,7 +1698,11 @@ void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& th
}
theIObj->UnsetWidth();
redisplayPrsRecModes (theIObj, theToUpdateViewer);
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1751,7 +1720,11 @@ void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& t
setContextToObject (theIObj);
theIObj->SetMaterial (theMaterial);
redisplayPrsRecModes (theIObj, theToUpdateViewer);
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1766,7 +1739,11 @@ void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)&
return;
}
theIObj->UnsetMaterial();
redisplayPrsRecModes (theIObj, theToUpdateViewer);
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1796,7 +1773,11 @@ void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject
}
theIObj->SetTransparency (theValue);
redisplayPrsRecModes (theIObj, theToUpdateViewer);
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
@@ -1812,7 +1793,11 @@ void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObje
}
theIObj->UnsetTransparency();
redisplayPrsRecModes (theIObj, theToUpdateViewer);
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================

View File

@@ -1082,6 +1082,7 @@ public: //! @name iso-line display attributes
//! Returns true if drawing isolines on triangulation algorithm is enabled.
Standard_EXPORT Standard_Boolean IsoOnTriangulation() const;
//! @name obsolete methods
public:
//! Updates the view of the current object in open context.
@@ -1207,14 +1208,6 @@ protected: //! @name internal methods
Standard_EXPORT void InitAttributes();
Standard_EXPORT Standard_Integer PurgeViewer (const Handle(V3d_Viewer)& Vwr);
//! UNKNOWN
Standard_EXPORT void redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Boolean theToUpdateViewer);
//! UNKNOWN
Standard_EXPORT void redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Boolean theToUpdateViewer);
//! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
Standard_EXPORT void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject);

View File

@@ -52,12 +52,11 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject)
AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: SelectMgr_SelectableObject (aTypeOfPresentation3d),
myCTXPtr (NULL),
myOwnWidth (0.0),
myOwnWidth (0.0f),
myCurrentFacingModel (Aspect_TOFM_BOTH_SIDE),
myInfiniteState (Standard_False),
hasOwnColor (Standard_False),
hasOwnMaterial (Standard_False),
myRecomputeEveryPrs (Standard_True)
hasOwnMaterial (Standard_False)
{
SetCurrentFacingModel();
}
@@ -90,14 +89,6 @@ AIS_KindOfInteractive AIS_InteractiveObject::Type() const
Standard_Integer AIS_InteractiveObject::Signature() const
{return -1;}
//=======================================================================
//function : RecomputeEveryPrs
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::RecomputeEveryPrs() const
{return myRecomputeEveryPrs;}
//=======================================================================
//function :
//purpose :
@@ -200,7 +191,7 @@ void AIS_InteractiveObject::UnsetColor()
//=======================================================================
void AIS_InteractiveObject::SetWidth(const Standard_Real aValue)
{
myOwnWidth = aValue;
myOwnWidth = (Standard_ShortReal )aValue;
}
//=======================================================================
@@ -209,7 +200,7 @@ void AIS_InteractiveObject::SetWidth(const Standard_Real aValue)
//=======================================================================
void AIS_InteractiveObject::UnsetWidth()
{
myOwnWidth = 0.;
myOwnWidth = 0.0f;
}
//=======================================================================
@@ -333,32 +324,10 @@ void AIS_InteractiveObject::UnsetAttributes()
hasOwnColor = Standard_False;
hasOwnMaterial = Standard_False;
myOwnWidth = 0.0;
myOwnWidth = 0.0f;
myDrawer->SetTransparency (0.0f);
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::MustRecomputePrs(const Standard_Integer ) const
{}
//=======================================================================
//function :
//purpose :
//=======================================================================
const TColStd_ListOfInteger& AIS_InteractiveObject::ListOfRecomputeModes() const
{return myToRecomputeModes;}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetRecomputeOk()
{myToRecomputeModes.Clear();}
//=======================================================================
//function : AcceptDisplayMode
//purpose :

View File

@@ -283,7 +283,7 @@ public:
virtual void Color (Quantity_Color& theColor) const { theColor = myDrawer->Color(); }
//! Returns true if the Interactive Object has width.
Standard_Boolean HasWidth() const { return myOwnWidth != 0.0; }
Standard_Boolean HasWidth() const { return myOwnWidth != 0.0f; }
//! Returns the width setting of the Interactive Object.
Standard_Real Width() const { return myOwnWidth; }
@@ -395,36 +395,19 @@ protected:
//! and then modify them directly followed by SynchronizeAspects() call.
Standard_EXPORT void replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap);
private:
Standard_EXPORT virtual Standard_Boolean RecomputeEveryPrs() const;
Standard_EXPORT void MustRecomputePrs (const Standard_Integer aMode) const;
Standard_EXPORT const TColStd_ListOfInteger& ListOfRecomputeModes() const;
Standard_EXPORT void SetRecomputeOk();
protected:
//! The TypeOfPresention3d means that the interactive object
//! may have a presentation dependant of the view of Display.
Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
private:
protected:
AIS_InteractiveContext* myCTXPtr;
Handle(Standard_Transient) myOwner;
protected:
TColStd_ListOfInteger myToRecomputeModes;
Standard_Real myOwnWidth;
Standard_ShortReal myOwnWidth;
Aspect_TypeOfFacingModel myCurrentFacingModel;
Standard_Boolean myInfiniteState;
Standard_Boolean hasOwnColor;
Standard_Boolean hasOwnMaterial;
Standard_Boolean myRecomputeEveryPrs;
};

View File

@@ -41,52 +41,6 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Line,AIS_InteractiveObject)
//==================================================================
// function: FindLimits
// purpose:
//==================================================================
//unused
/*#ifdef OCCT_DEBUG
static void FindLimits(const Adaptor3d_Curve& aCurve,
const Standard_Real aLimit,
gp_Pnt& P1,
gp_Pnt& P2)
{
Standard_Real First = aCurve.FirstParameter();
Standard_Real Last = aCurve.LastParameter();
Standard_Boolean firstInf = Precision::IsNegativeInfinite(First);
Standard_Boolean lastInf = Precision::IsPositiveInfinite(Last);
if (firstInf || lastInf) {
Standard_Real delta = 1;
if (firstInf && lastInf) {
do {
delta *= 2;
First = - delta;
Last = delta;
aCurve.D0(First,P1);
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
else if (firstInf) {
aCurve.D0(Last,P2);
do {
delta *= 2;
First = Last - delta;
aCurve.D0(First,P1);
} while (P1.Distance(P2) < aLimit);
}
else if (lastInf) {
aCurve.D0(First,P1);
do {
delta *= 2;
Last = First + delta;
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
}
}
#endif
*/
//=======================================================================
//function : AIS_Line
//purpose :
@@ -126,8 +80,7 @@ void AIS_Line::Compute(const Handle(PrsMgr_PresentationManager3d)&,
void AIS_Line::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTransformation, const Handle(Prs3d_Presentation)& aPresentation)
{
// throw Standard_NotImplemented("AIS_Line::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
}
//=======================================================================
@@ -152,6 +105,29 @@ void AIS_Line::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
}
}
//=======================================================================
//function : replaceWithNewLineAspect
//purpose :
//=======================================================================
void AIS_Line::replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
{
if (!myDrawer->HasLink())
{
myDrawer->SetLineAspect (theAspect);
return;
}
const Handle(Graphic3d_Aspects)& anAspectOld = myDrawer->LineAspect()->Aspect();
const Handle(Graphic3d_Aspects)& anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
if (anAspectNew != anAspectOld)
{
myDrawer->SetLineAspect (theAspect);
Graphic3d_MapOfAspectsToAspects aReplaceMap;
aReplaceMap.Bind (anAspectOld, anAspectNew);
replaceAspects (aReplaceMap);
}
}
//=======================================================================
//function : SetColor
//purpose :
@@ -165,10 +141,15 @@ void AIS_Line::SetColor(const Quantity_Color &aCol)
myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.;
if (!myDrawer->HasOwnLineAspect ())
myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
if (!myDrawer->HasOwnLineAspect())
{
replaceWithNewLineAspect (new Prs3d_LineAspect (aCol, Aspect_TOL_SOLID, WW));
}
else
myDrawer->LineAspect()->SetColor(aCol);
{
myDrawer->LineAspect()->SetColor (aCol);
SynchronizeAspects();
}
}
@@ -180,16 +161,19 @@ void AIS_Line::UnsetColor()
{
hasOwnColor = Standard_False;
Handle(Prs3d_LineAspect) NullAsp;
if (!HasWidth()) myDrawer->SetLineAspect(NullAsp);
else{
if (!HasWidth())
{
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)());
}
else
{
Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myDrawer->Color();
else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
myDrawer->LineAspect()->SetColor(CC);
myDrawer->SetColor (CC);
}
SynchronizeAspects();
}
}
//=======================================================================
@@ -198,15 +182,20 @@ void AIS_Line::UnsetColor()
//=======================================================================
void AIS_Line::SetWidth(const Standard_Real aValue)
{
myOwnWidth=aValue;
myOwnWidth = (Standard_ShortReal )aValue;
if (!myDrawer->HasOwnLineAspect ()) {
if (!myDrawer->HasOwnLineAspect())
{
Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myDrawer->Color();
else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
myDrawer->SetLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue));
} else
myDrawer->LineAspect()->SetWidth(aValue);
replaceWithNewLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue));
}
else
{
myDrawer->LineAspect()->SetWidth (aValue);
SynchronizeAspects();
}
}
@@ -216,14 +205,16 @@ void AIS_Line::SetWidth(const Standard_Real aValue)
//=======================================================================
void AIS_Line::UnsetWidth()
{
Handle(Prs3d_LineAspect) NullAsp;
if (!HasColor()) myDrawer->SetLineAspect(NullAsp);
else{
Standard_Real WW = myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.;
myDrawer->LineAspect()->SetWidth(WW);
if (!HasColor())
{
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)());
}
else
{
Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.0f;
myDrawer->LineAspect()->SetWidth (WW);
myOwnWidth = WW;
SynchronizeAspects();
}
}

View File

@@ -107,6 +107,9 @@ private:
Standard_EXPORT void ComputeSegmentLineSelection (const Handle(SelectMgr_Selection)& aSelection);
//! Replace aspects of already computed groups with the new value.
void replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect);
private:
Handle(Geom_Line) myComponent;

View File

@@ -387,7 +387,8 @@ void AIS_Plane::SetSize(const Standard_Real aXLength,
myHasOwnSize = Standard_True;
Update();
SetToUpdate();
UpdatePresentations();
UpdateSelection();
}
@@ -418,7 +419,8 @@ void AIS_Plane::UnsetSize()
}
myHasOwnSize = Standard_False;
Update();
SetToUpdate();
UpdatePresentations();
UpdateSelection();
}

View File

@@ -248,6 +248,7 @@ void AIS_PlaneTrihedron::SetColor(const Quantity_Color &aCol)
myDrawer->SetColor (aCol);
myDrawer->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetColor(aCol);
myDrawer->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetColor(aCol);
SynchronizeAspects();
}

View File

@@ -89,7 +89,7 @@ public:
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Datum; }
//! Allows you to provide settings for the color aColor.
Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
void SetXLabel (const TCollection_AsciiString& theLabel) { myXLabel = theLabel; }

View File

@@ -205,6 +205,29 @@ void AIS_Point::UnsetMarker()
|| theMode == -99;
}
//=======================================================================
//function : replaceWithNewPointAspect
//purpose :
//=======================================================================
void AIS_Point::replaceWithNewPointAspect (const Handle(Prs3d_PointAspect)& theAspect)
{
if (!myDrawer->HasLink())
{
myDrawer->SetPointAspect (theAspect);
return;
}
const Handle(Graphic3d_AspectMarker3d) anAspectOld = myDrawer->PointAspect()->Aspect();
const Handle(Graphic3d_AspectMarker3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->PointAspect()->Aspect();
if (anAspectNew != anAspectOld)
{
myDrawer->SetPointAspect (theAspect);
Graphic3d_MapOfAspectsToAspects aReplaceMap;
aReplaceMap.Bind (anAspectOld, anAspectNew);
replaceAspects (aReplaceMap);
}
}
//=======================================================================
//function : UpdatePointValues
//purpose :
@@ -212,12 +235,14 @@ void AIS_Point::UnsetMarker()
void AIS_Point::UpdatePointValues()
{
if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM)
if (!hasOwnColor
&& myOwnWidth == 0.0f
&& !myHasTOM)
{
myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
replaceWithNewPointAspect (Handle(Prs3d_PointAspect)());
return;
}
Quantity_Color aCol (Quantity_NOC_YELLOW);
Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS;
Standard_Real aScale = 1.0;
@@ -229,20 +254,20 @@ void AIS_Point::UpdatePointValues()
}
if(hasOwnColor) aCol = myDrawer->Color();
if(myOwnWidth!=0.0) aScale = myOwnWidth;
if(myOwnWidth != 0.0f) aScale = myOwnWidth;
if(myHasTOM) aTOM = myTOM;
if(myDrawer->HasOwnPointAspect()){
// CLE
// const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
if(myDrawer->HasOwnPointAspect())
{
Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
// ENDCLE
PA->SetColor(aCol);
PA->SetTypeOfMarker(aTOM);
PA->SetScale(aScale);
SynchronizeAspects();
}
else
myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));
{
replaceWithNewPointAspect (new Prs3d_PointAspect (aTOM, aCol, aScale));
}
}

View File

@@ -59,10 +59,10 @@ public:
Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
//! Allows you to provide settings for the Color.
Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
//! Allows you to remove color settings.
Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
//! Allows you to provide settings for a marker. These include
//! - type of marker,
@@ -91,6 +91,9 @@ private:
Standard_EXPORT void UpdatePointValues();
//! Replace aspects of already computed groups with the new value.
void replaceWithNewPointAspect (const Handle(Prs3d_PointAspect)& theAspect);
private:
Handle(Geom_Point) myComponent;

View File

@@ -68,15 +68,6 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject)
static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode)
{
TColStd_ListIteratorOfListOfInteger It(LL);
for(;It.More();It.Next()){
if(It.Value()==aMode)
return Standard_True;}
return Standard_False;
}
// Auxiliary macros
#define replaceAspectWithDef(theMap, theAspect) \
if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
@@ -411,8 +402,6 @@ void AIS_Shape::SetColor (const Quantity_Color& theColor)
myDrawer->SetColor (theColor);
hasOwnColor = Standard_True;
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (!toRecompute
|| !myDrawer->HasLink())
{
@@ -432,8 +421,6 @@ void AIS_Shape::SetColor (const Quantity_Color& theColor)
void AIS_Shape::UnsetColor()
{
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (!HasColor())
{
return;
@@ -578,10 +565,8 @@ bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
{
myOwnWidth = theLineWidth;
myOwnWidth = (Standard_ShortReal )theLineWidth;
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (!setWidth (myDrawer, theLineWidth)
|| !myDrawer->HasLink())
{
@@ -601,14 +586,12 @@ void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
void AIS_Shape::UnsetWidth()
{
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (myOwnWidth == 0.0)
if (myOwnWidth == 0.0f)
{
return;
}
myOwnWidth = 0.0;
myOwnWidth = 0.0f;
if (!HasColor())
{
Graphic3d_MapOfAspectsToAspects aReplaceMap;
@@ -681,8 +664,6 @@ void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
hasOwnMaterial = Standard_True;
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (!toRecompute
|| !myDrawer->HasLink())
{
@@ -701,8 +682,6 @@ void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
void AIS_Shape::UnsetMaterial()
{
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (!HasMaterial())
{
return;
@@ -761,8 +740,6 @@ void AIS_Shape::SetTransparency (const Standard_Real theValue)
setTransparency (myDrawer, theValue);
myDrawer->SetTransparency ((Standard_ShortReal )theValue);
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (!toRecompute
|| !myDrawer->HasLink())
{
@@ -781,9 +758,6 @@ void AIS_Shape::SetTransparency (const Standard_Real theValue)
void AIS_Shape::UnsetTransparency()
{
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
myDrawer->SetTransparency (0.0f);
if (!myDrawer->HasOwnShadingAspect())
{
@@ -805,18 +779,6 @@ void AIS_Shape::UnsetTransparency()
}
}
//=======================================================================
//function : LoadRecomputable
//purpose :
//=======================================================================
void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode)
{
myRecomputeEveryPrs = Standard_False;
if(!IsInList(myToRecomputeModes,TheMode))
myToRecomputeModes.Append(TheMode);
}
//=======================================================================
//function : BoundingBox
//purpose :
@@ -903,8 +865,7 @@ Standard_Boolean AIS_Shape::SetOwnHLRDeviationAngle ()
void AIS_Shape::SetOwnDeviationCoefficient ( const Standard_Real aCoefficient )
{
myDrawer->SetDeviationCoefficient( aCoefficient );
SetToUpdate(0) ; // WireFrame
SetToUpdate(1) ; // Shadding
SetToUpdate();
}
//=======================================================================
@@ -923,11 +884,10 @@ void AIS_Shape::SetOwnHLRDeviationCoefficient ( const Standard_Real aCoefficien
//purpose :
//=======================================================================
void AIS_Shape::SetOwnDeviationAngle ( const Standard_Real anAngle )
void AIS_Shape::SetOwnDeviationAngle (const Standard_Real theAngle)
{
myDrawer->SetDeviationAngle(anAngle );
SetToUpdate(0) ; // WireFrame
myDrawer->SetDeviationAngle (theAngle);
SetToUpdate (AIS_WireFrame);
}
//=======================================================================
//function : SetOwnDeviationAngle
@@ -941,8 +901,7 @@ void AIS_Shape::SetAngleAndDeviation ( const Standard_Real anAngle )
SetOwnDeviationAngle(anAngle) ;
SetOwnDeviationCoefficient(OutDefl) ;
myInitAng = anAngle;
SetToUpdate(0);
SetToUpdate(1);
SetToUpdate();
}
//=======================================================================

View File

@@ -302,8 +302,6 @@ protected:
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT void LoadRecomputable (const Standard_Integer TheMode);
//! Create own aspects (if they do not exist) and set color to them.
//! @return TRUE if new aspects have been created
Standard_EXPORT bool setColor (const Handle(Prs3d_Drawer)& theDrawer, const Quantity_Color& theColor) const;

View File

@@ -57,6 +57,7 @@ void AIS_TextLabel::SetColor (const Quantity_Color& theColor)
hasOwnColor = Standard_True;
myDrawer->SetColor (theColor);
myDrawer->TextAspect()->SetColor (theColor);
SynchronizeAspects();
}
//=======================================================================
@@ -74,6 +75,7 @@ void AIS_TextLabel::SetTransparency (const Standard_Real theValue)
myDrawer->TextAspect()->Aspect()->SetColor (aTextColor);
myDrawer->TextAspect()->Aspect()->SetColorSubTitle (aSubColor);
myDrawer->SetTransparency (Standard_ShortReal(theValue));
SynchronizeAspects();
}
//=======================================================================

View File

@@ -111,9 +111,6 @@ void AIS_Triangulation::updatePresentation()
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
}
myRecomputeEveryPrs = Standard_False; // no mode to recalculate - only viewer update
myToRecomputeModes.Clear();
}
}

View File

@@ -85,7 +85,7 @@ AIS_Trihedron::AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent)
void AIS_Trihedron::SetComponent (const Handle(Geom_Axis2Placement)& theComponent)
{
myComponent = theComponent;
LoadRecomputable (AIS_WireFrame);
SetToUpdate();
}
//=======================================================================
@@ -135,7 +135,8 @@ void AIS_Trihedron::SetSize(const Standard_Real aValue)
setOwnDatumAspect();
myDrawer->DatumAspect()->SetAxisLength(aValue, aValue, aValue);
Update();
SetToUpdate();
UpdatePresentations();
UpdateSelection();
}
@@ -162,7 +163,8 @@ void AIS_Trihedron::UnsetSize()
}
else
{
Update();
SetToUpdate();
UpdatePresentations();
}
UpdateSelection();
}
@@ -560,19 +562,6 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
}
}
//=======================================================================
//function : LoadRecomputable
//purpose :
//=======================================================================
void AIS_Trihedron::LoadRecomputable (const Standard_Integer theMode)
{
myRecomputeEveryPrs = Standard_False;
if (!myToRecomputeModes.Contains (theMode))
{
myToRecomputeModes.Append (theMode);
}
}
//=======================================================================
//function : SetColor
//purpose :

View File

@@ -224,8 +224,6 @@ protected:
protected:
Standard_EXPORT void LoadRecomputable (const Standard_Integer theMode);
//! Creates a sensitive entity for the datum part that will be used in selection owner creation.
Standard_EXPORT Handle(SelectBasics_SensitiveEntity) createSensitiveEntity (const Prs3d_DatumParts thePart,
const Handle(SelectBasics_EntityOwner)& theOwner) const;

View File

@@ -34,14 +34,14 @@
//=======================================================================
Approx_ComputeCLine::Approx_ComputeCLine
(const MultiLine& Line,
const Standard_Integer degreemin,
const Standard_Integer degreemax,
const Standard_Real Tolerance3d,
const Standard_Real Tolerance2d,
const Standard_Boolean cutting,
const AppParCurves_Constraint FirstC,
const AppParCurves_Constraint LastC)
(const MultiLine& Line,
const Standard_Integer degreemin,
const Standard_Integer degreemax,
const Standard_Real Tolerance3d,
const Standard_Real Tolerance2d,
const Standard_Boolean cutting,
const AppParCurves_Constraint FirstC,
const AppParCurves_Constraint LastC)
{
mydegremin = degreemin;
mydegremax = degreemax;
@@ -61,13 +61,13 @@ Approx_ComputeCLine::Approx_ComputeCLine
//=======================================================================
Approx_ComputeCLine::Approx_ComputeCLine
(const Standard_Integer degreemin,
const Standard_Integer degreemax,
const Standard_Real Tolerance3d,
const Standard_Real Tolerance2d,
const Standard_Boolean cutting,
const AppParCurves_Constraint FirstC,
const AppParCurves_Constraint LastC)
(const Standard_Integer degreemin,
const Standard_Integer degreemax,
const Standard_Real Tolerance3d,
const Standard_Real Tolerance2d,
const Standard_Boolean cutting,
const AppParCurves_Constraint FirstC,
const AppParCurves_Constraint LastC)
{
alldone = Standard_False;
mydegremin = degreemin;
@@ -88,21 +88,22 @@ Approx_ComputeCLine::Approx_ComputeCLine
void Approx_ComputeCLine::Perform(const MultiLine& Line)
{
Standard_Real UFirst, ULast;
Standard_Boolean Finish = Standard_False,
begin = Standard_True, Ok = Standard_False;
Standard_Boolean Finish = Standard_False,
begin = Standard_True, Ok = Standard_False;
Standard_Real thetol3d = Precision::Confusion(), thetol2d = Precision::Confusion();
UFirst = Line.FirstParameter();
ULast = Line.LastParameter();
Standard_Real TolU = Max((ULast-UFirst)*1.e-05, Precision::PApproximation());
Standard_Real myfirstU = UFirst;
ULast = Line.LastParameter();
Standard_Real TolU = Max((ULast - UFirst)*1.e-03, Precision::Confusion());
Standard_Real myfirstU = UFirst;
Standard_Real mylastU = ULast;
Standard_Integer aMaxSegments = 0;
Standard_Integer aMaxSegments1 = myMaxSegments - 1;
Standard_Integer aNbCut = 0, aNbImp = 0, aNbComp = 5;
if (!mycut)
{
alldone = Compute(Line, UFirst, ULast, thetol3d, thetol2d);
if (!alldone)
if (!alldone)
{
tolreached = Standard_False;
myfirstparam.Append(UFirst);
@@ -112,25 +113,27 @@ void Approx_ComputeCLine::Perform(const MultiLine& Line)
Tolers2d.Append(currenttol2d);
}
}
else
else
{
// previous decision to be taken if we get worse with next cut (eap)
AppParCurves_MultiCurve KeptMultiCurve;
Standard_Real KeptUfirst = 0., KeptUlast = 0., KeptT3d = RealLast(), KeptT2d = 0.;
while (!Finish)
while (!Finish)
{
// Gestion du decoupage de la multiline pour approximer:
if (!begin)
if (!begin)
{
if (Ok)
if (Ok)
{
// Calcul de la partie a approximer.
myfirstU = mylastU;
mylastU = ULast;
if (Abs(ULast-myfirstU) <= RealEpsilon()
mylastU = ULast;
aNbCut = 0;
aNbImp = 0;
if (Abs(ULast - myfirstU) <= RealEpsilon()
|| aMaxSegments >= myMaxSegments)
{
Finish = Standard_True;
@@ -147,50 +150,59 @@ void Approx_ComputeCLine::Perform(const MultiLine& Line)
if ((thetol3d + thetol2d) < (KeptT3d + KeptT2d))
{
KeptMultiCurve = TheMultiCurve;
KeptUfirst = myfirstU;
KeptUlast = mylastU;
KeptT3d = thetol3d;
KeptT2d = thetol2d;
KeptUfirst = myfirstU;
KeptUlast = mylastU;
KeptT3d = thetol3d;
KeptT2d = thetol2d;
aNbImp++;
}
// cut an interval
mylastU = (myfirstU + mylastU)/2;
mylastU = (myfirstU + mylastU) / 2;
aNbCut++;
}
}
// Calcul des parametres sur ce nouvel intervalle.
Ok = Compute(Line, myfirstU, mylastU, thetol3d, thetol2d);
if(Ok)
if (Ok)
{
aMaxSegments++;
}
//cout << myfirstU << " - " << mylastU << " tol : " << thetol3d << " " << thetol2d << endl;
// is new decision better?
if (!Ok && (Abs(myfirstU-mylastU) <= TolU || aMaxSegments >= aMaxSegments1))
Standard_Boolean aStopCutting = Standard_False;
if (aNbCut >= aNbComp)
{
Ok = Standard_True; // stop interval cutting, approx the rest part
if ((thetol3d + thetol2d) < (KeptT3d + KeptT2d))
{
KeptMultiCurve = TheMultiCurve;
KeptUfirst = myfirstU;
KeptUlast = mylastU;
KeptT3d = thetol3d;
KeptT2d = thetol2d;
}
mylastU = KeptUlast;
tolreached = Standard_False; // helas
myMultiCurves.Append(KeptMultiCurve);
aMaxSegments++;
Tolers3d.Append (KeptT3d);
Tolers2d.Append (KeptT2d);
myfirstparam.Append (KeptUfirst);
mylastparam.Append (KeptUlast);
if (aNbCut > aNbImp)
{
aStopCutting = Standard_True;
}
}
// is new decision better?
if (!Ok && (Abs(myfirstU - mylastU) <= TolU || aMaxSegments >= aMaxSegments1 || aStopCutting ))
{
Ok = Standard_True; // stop interval cutting, approx the rest part
if ((thetol3d + thetol2d) < (KeptT3d + KeptT2d))
{
KeptMultiCurve = TheMultiCurve;
KeptUfirst = myfirstU;
KeptUlast = mylastU;
KeptT3d = thetol3d;
KeptT2d = thetol2d;
}
mylastU = KeptUlast;
tolreached = Standard_False; // helas
myMultiCurves.Append(KeptMultiCurve);
aMaxSegments++;
Tolers3d.Append(KeptT3d);
Tolers2d.Append(KeptT2d);
myfirstparam.Append(KeptUfirst);
mylastparam.Append(KeptUlast);
}
begin = Standard_False;
} // while (!Finish)
@@ -225,10 +237,10 @@ const
//=======================================================================
Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
const Standard_Real Ufirst,
const Standard_Real Ulast,
Standard_Real& TheTol3d,
Standard_Real& TheTol2d)
const Standard_Real Ufirst,
const Standard_Real Ulast,
Standard_Real& TheTol3d,
Standard_Real& TheTol2d)
{
@@ -243,14 +255,14 @@ Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
if (mydone) {
LSquare.Error(Fv, TheTol3d, TheTol2d);
if (TheTol3d <= mytol3d && TheTol2d <= mytol2d) {
// Stockage de la multicurve approximee.
tolreached = Standard_True;
// Stockage de la multicurve approximee.
tolreached = Standard_True;
myMultiCurves.Append(LSquare.Value());
myfirstparam.Append(Ufirst);
mylastparam.Append(Ulast);
Tolers3d.Append(TheTol3d);
Tolers2d.Append(TheTol2d);
return Standard_True;
myfirstparam.Append(Ufirst);
mylastparam.Append(Ulast);
Tolers3d.Append(TheTol3d);
Tolers2d.Append(TheTol2d);
return Standard_True;
}
}
if (deg == mydegremax) {
@@ -258,7 +270,7 @@ Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
currenttol3d = TheTol3d;
currenttol2d = TheTol2d;
}
}
return Standard_False;
}
@@ -270,11 +282,11 @@ Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
//=======================================================================
void Approx_ComputeCLine::Parameters(const Standard_Integer Index,
Standard_Real& firstpar,
Standard_Real& lastpar) const
Standard_Real& firstpar,
Standard_Real& lastpar) const
{
firstpar = myfirstparam.Value(Index);
lastpar = mylastparam.Value(Index);
lastpar = mylastparam.Value(Index);
}
//=======================================================================
@@ -283,7 +295,7 @@ void Approx_ComputeCLine::Parameters(const Standard_Integer Index,
//=======================================================================
void Approx_ComputeCLine::SetDegrees(const Standard_Integer degreemin,
const Standard_Integer degreemax)
const Standard_Integer degreemax)
{
mydegremin = degreemin;
mydegremax = degreemax;
@@ -295,7 +307,7 @@ void Approx_ComputeCLine::SetDegrees(const Standard_Integer degreemin,
//=======================================================================
void Approx_ComputeCLine::SetTolerances(const Standard_Real Tolerance3d,
const Standard_Real Tolerance2d)
const Standard_Real Tolerance2d)
{
mytol3d = Tolerance3d;
mytol2d = Tolerance2d;
@@ -307,10 +319,10 @@ void Approx_ComputeCLine::SetTolerances(const Standard_Real Tolerance3d,
//=======================================================================
void Approx_ComputeCLine::SetConstraints(const AppParCurves_Constraint FirstC,
const AppParCurves_Constraint LastC)
const AppParCurves_Constraint LastC)
{
myfirstC = FirstC;
mylastC = LastC;
mylastC = LastC;
}
//=======================================================================
@@ -318,7 +330,7 @@ void Approx_ComputeCLine::SetConstraints(const AppParCurves_Constraint FirstC,
//purpose : Changes the max number of segments, which is allowed for cutting.
//=======================================================================
void Approx_ComputeCLine:: SetMaxSegments(const Standard_Integer theMaxSegments)
void Approx_ComputeCLine::SetMaxSegments(const Standard_Integer theMaxSegments)
{
myMaxSegments = theMaxSegments;
}
@@ -351,8 +363,8 @@ const {
//=======================================================================
void Approx_ComputeCLine::Error(const Standard_Integer Index,
Standard_Real& tol3d,
Standard_Real& tol2d) const
Standard_Real& tol3d,
Standard_Real& tol2d) const
{
tol3d = Tolers3d.Value(Index);
tol2d = Tolers2d.Value(Index);

View File

@@ -163,12 +163,21 @@ void Approx_SweepApproximation::Perform(const Standard_Real First,
myDWeigths = new (TColStd_HArray1OfReal)(1, Num3DSS);
myD2Weigths = new (TColStd_HArray1OfReal)(1, Num3DSS);
if (Num2DSS>0) {
if (Num2DSS>0)
{
myPoles2d = new (TColgp_HArray1OfPnt2d)(1, Num2DSS);
myDPoles2d = new (TColgp_HArray1OfVec2d)(1, Num2DSS);
myD2Poles2d = new (TColgp_HArray1OfVec2d)(1, Num2DSS);
COnSurfErr = new (TColStd_HArray1OfReal)(1, Num2DSS);
}
else
{
myPoles2d = new TColgp_HArray1OfPnt2d();
myDPoles2d = new TColgp_HArray1OfVec2d();
myD2Poles2d = new TColgp_HArray1OfVec2d();
COnSurfErr = new TColStd_HArray1OfReal();
}
// Checks if myFunc->D2 is implemented
if (continuity >= GeomAbs_C2) {
Standard_Boolean B;

View File

@@ -147,7 +147,6 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
if ( ! aRes.IsNull() )
{
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S);
}
}

View File

@@ -238,19 +238,27 @@ static Standard_Boolean KPartCircle
BRepFill_IndexedDataMapOfOrientedShapeListOfShape& myMap,
Standard_Boolean& myIsDone)
{
TopExp_Explorer exp(mySpine,TopAbs_EDGE);
Standard_Integer NbEdges = 0;
TopoDS_Edge E;
for (; exp.More(); exp.Next()) {
NbEdges++;
E = TopoDS::Edge(exp.Current());
if (NbEdges > 1) return Standard_False;
TopoDS_Edge E;
for (TopExp_Explorer anEdgeIter (mySpine, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next())
{
if (!E.IsNull())
{
return Standard_False;
}
E = TopoDS::Edge (anEdgeIter.Current());
}
if (E.IsNull())
{
return Standard_False;
}
Standard_Real f,l;
TopLoc_Location L;
Handle(Geom_Curve) C = BRep_Tool::Curve(E,L,f,l);
if (C.IsNull())
{
return Standard_False;
}
if (C->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) Ct = Handle(Geom_TrimmedCurve)::DownCast(C);
@@ -741,7 +749,6 @@ void BRepFill_OffsetWire::PerformWithBiLo
return;
BRep_Builder myBuilder;
myBuilder.MakeCompound(TopoDS::Compound(myShape));
//---------------------------------------------------------------------
// MapNodeVertex : associate to each node of the map (key1) and to
@@ -785,6 +792,11 @@ void BRepFill_OffsetWire::PerformWithBiLo
TopExp::Vertices(theWire, Ends[0], Ends[1]);
}
if (Locus.NumberOfContours() == 0)
{
return;
}
for (Standard_Integer ic = 1; ic <= Locus.NumberOfContours(); ic++) {
TopoDS_Shape PEE = Link.GeneratingShape(Locus.BasicElt(ic,Locus.NumberOfElts(ic)));
TopoDS_Shape& PE = PEE ;

View File

@@ -131,10 +131,10 @@ BRepLib_MakeWire::BRepLib_MakeWire(const TopoDS_Wire& W,
void BRepLib_MakeWire::Add(const TopoDS_Wire& W)
{
TopExp_Explorer ex(W,TopAbs_EDGE);
while (ex.More()) {
Add(TopoDS::Edge(ex.Current()));
ex.Next();
for (TopoDS_Iterator it(W); it.More(); it.Next()) {
Add(TopoDS::Edge(it.Value()));
if (myError != BRepLib_WireDone)
break;
}
}

View File

@@ -24,10 +24,10 @@
#include <BRepLib_WireError.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <BRepLib_MakeShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <NCollection_Map.hxx>
#include <Bnd_Box.hxx>
#include <NCollection_UBTree.hxx>
@@ -172,14 +172,14 @@ private:
};
void CollectCoincidentVertices(const TopTools_ListOfShape& theL,
NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL);
NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL);
void CreateNewVertices(const NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL,
NCollection_DataMap<TopoDS_Vertex, TopoDS_Vertex>& theO2NV);
TopTools_DataMapOfShapeShape& theO2NV);
void CreateNewListOfEdges(const TopTools_ListOfShape& theL,
const NCollection_DataMap<TopoDS_Vertex, TopoDS_Vertex>& theO2NV,
TopTools_ListOfShape& theNewEList);
const TopTools_DataMapOfShapeShape& theO2NV,
TopTools_ListOfShape& theNewEList);
void Add(const TopoDS_Edge& E, Standard_Boolean IsCheckGeometryProximity);

View File

@@ -58,7 +58,7 @@ void BRepLib_MakeWire::Add(const TopTools_ListOfShape& L)
CollectCoincidentVertices(L, aGrVL);
NCollection_DataMap<TopoDS_Vertex, TopoDS_Vertex> anO2NV;
TopTools_DataMapOfShapeShape anO2NV;
CreateNewVertices(aGrVL, anO2NV);
@@ -188,17 +188,13 @@ void BRepLib_MakeWire::CollectCoincidentVertices(const TopTools_ListOfShape& the
NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL)
{
TopTools_IndexedMapOfShape anAllV;
TopTools_ListIteratorOfListOfShape anItL;
TopTools_IndexedDataMapOfShapeListOfShape aMV2EL;
TopExp::MapShapesAndAncestors(myShape, TopAbs_VERTEX, TopAbs_EDGE, aMV2EL);
TopExp_Explorer exp;
for (anItL.Initialize(theL); anItL.More(); anItL.Next())
TopExp::MapShapesAndAncestors(anItL.Value(), TopAbs_VERTEX, TopAbs_EDGE, aMV2EL);
TopExp::MapShapes(myShape, TopAbs_VERTEX, anAllV);
for (int i = 1; i <= aMV2EL.Extent(); i++)
if (aMV2EL(i).Extent() == 1)
anAllV.Add(aMV2EL.FindKey(i));
TopTools_ListIteratorOfListOfShape anItL(theL);
for (; anItL.More(); anItL.Next())
TopExp::MapShapes(anItL.Value(), TopAbs_VERTEX, anAllV);
//aV2CV : vertex <-> its coincident vertices
NCollection_DataMap<TopoDS_Vertex, NCollection_Map<TopoDS_Vertex>> aV2CV;
@@ -303,8 +299,8 @@ void BRepLib_MakeWire::CollectCoincidentVertices(const TopTools_ListOfShape& the
//function : CreateNewVertices
//purpose :
//=======================================================================
void BRepLib_MakeWire::CreateNewVertices(const NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL,
NCollection_DataMap<TopoDS_Vertex, TopoDS_Vertex>& theO2NV)
void BRepLib_MakeWire::CreateNewVertices(const NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL,
TopTools_DataMapOfShapeShape& theO2NV)
{
//map [old vertex => new vertex]
//note that already existing shape (i.e. the original ones)
@@ -356,7 +352,7 @@ void BRepLib_MakeWire::CreateNewVertices(const NCollection_List<NCollection_List
//purpose :
//=======================================================================
void BRepLib_MakeWire::CreateNewListOfEdges(const TopTools_ListOfShape& theL,
const NCollection_DataMap<TopoDS_Vertex, TopoDS_Vertex>& theO2NV,
const TopTools_DataMapOfShapeShape& theO2NV,
TopTools_ListOfShape& theNewEList)
{
///create the new list (theNewEList) from the input list L

View File

@@ -70,7 +70,12 @@ void BRepMAT2d_BisectingLocus::Compute(BRepMAT2d_Explorer& anExplo,
Standard_Integer i;
nbSect.Clear();
theGraph = new MAT_Graph();
nbContours = anExplo.NumberOfContours();
if (nbContours == 0)
{
return;
}
//---------------------------------
// Lecture des donnees de anExplo.
@@ -121,7 +126,6 @@ void BRepMAT2d_BisectingLocus::Compute(BRepMAT2d_Explorer& anExplo,
TheRoots->BackAdd(TheMAT.Bisector());
}
theGraph = new MAT_Graph();
theGraph->Perform(TheMAT.SemiInfinite(),
TheRoots,
theTool.NumberOfItems(),

View File

@@ -123,12 +123,6 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
const TopoDS_Face& aFace,
TopoDS_Face& aNewFace)
{
// Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin
// This method is totally rewroted to include check
// of connection and creation of a new spine.
NewContour();
myIsClosed(currentContour) = (Spine.Closed()) ? Standard_True : Standard_False;
// Modified by skv - Wed Jun 23 12:23:01 2004 Integration Begin
// Taking into account side of bisecting loci construction.
// TopoDS_Wire aWFwd = TopoDS::Wire(Spine.Oriented(TopAbs_FORWARD));
@@ -136,10 +130,15 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
BRepTools_WireExplorer anExp(Spine, aFace);
// Modified by skv - Wed Jun 23 12:23:02 2004 Integration End
TopTools_IndexedDataMapOfShapeShape anOldNewE;
if (!anExp.More())
return;
// Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin
// This method is totally rewroted to include check
// of connection and creation of a new spine.
NewContour();
myIsClosed(currentContour) = (Spine.Closed()) ? Standard_True : Standard_False;
TopoDS_Edge aFirstEdge = anExp.Current();
TopoDS_Edge aPrevEdge = aFirstEdge;
Standard_Real UFirst,ULast, aD;

View File

@@ -3103,6 +3103,7 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
TopLoc_Location L;
Handle (Geom_Surface) S = BRep_Tool::Surface(F,L);
Standard_Real UU1,VV1,UU2,VV2;
Standard_Boolean uperiodic = Standard_False, vperiodic = Standard_False;
Standard_Boolean isVV1degen = Standard_False, isVV2degen = Standard_False;
Standard_Real US1,VS1,US2,VS2;
Standard_Real UF1,VF1,UF2,VF2;
@@ -3146,6 +3147,7 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
}
if (S->IsUPeriodic()) {
uperiodic = Standard_True;
Standard_Real Period = S->UPeriod();
Standard_Real Delta = Period - (UF2 - UF1);
Standard_Real alpha = 0.1;
@@ -3155,6 +3157,7 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
}
}
if (S->IsVPeriodic()) {
vperiodic = Standard_True;
Standard_Real Period = S->VPeriod();
Standard_Real Delta = Period - (VF2 - VF1);
Standard_Real alpha = 0.1;
@@ -3199,6 +3202,12 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
//Detect closedness in U and V directions
Standard_Boolean uclosed = Standard_False, vclosed = Standard_False;
BRepTools::DetectClosedness(F, uclosed, vclosed);
if (uclosed && !uperiodic &&
(theLenBeforeUfirst != 0. || theLenAfterUlast != 0.))
uclosed = Standard_False;
if (vclosed && !vperiodic &&
(theLenBeforeVfirst != 0. && theLenAfterVlast != 0.))
vclosed = Standard_False;
MakeFace(S,UU1,UU2,VV1,VV2,uclosed,vclosed,isVV1degen,isVV2degen,BF);
BF.Location(L);

View File

@@ -67,25 +67,6 @@
#include <errno.h>
//=======================================================================
//function : IsPCurveUiso
//purpose :
//=======================================================================
static Standard_Boolean IsPCurveUiso(const Handle(Geom2d_Curve)& thePCurve,
Standard_Real theFirstPar,
Standard_Real theLastPar)
{
gp_Pnt2d FirstP2d = thePCurve->Value(theFirstPar);
gp_Pnt2d LastP2d = thePCurve->Value(theLastPar);
Standard_Real DeltaU = Abs(FirstP2d.X() - LastP2d.X());
Standard_Real DeltaV = Abs(FirstP2d.Y() - LastP2d.Y());
return (DeltaU < DeltaV);
}
//=======================================================================
//function : UVBounds
//purpose :
@@ -977,28 +958,24 @@ void BRepTools::DetectClosedness(const TopoDS_Face& theFace,
{
theUclosed = theVclosed = Standard_False;
BRepAdaptor_Surface BAsurf(theFace, Standard_False);
Standard_Boolean IsSurfUclosed = BAsurf.IsUClosed();
Standard_Boolean IsSurfVclosed = BAsurf.IsVClosed();
if (!IsSurfUclosed && !IsSurfVclosed)
return;
TopExp_Explorer Explo(theFace, TopAbs_EDGE);
for (; Explo.More(); Explo.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current());
if (BRepTools::IsReallyClosed(anEdge, theFace))
if (BRep_Tool::IsClosed(anEdge, theFace) &&
BRepTools::IsReallyClosed(anEdge, theFace))
{
Standard_Real fpar, lpar;
Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge, theFace, fpar, lpar);
Standard_Boolean IsUiso = IsPCurveUiso(aPCurve, fpar, lpar);
if (IsSurfUclosed && IsUiso)
Handle(Geom2d_Curve) PCurve1 = BRep_Tool::CurveOnSurface(anEdge, theFace, fpar, lpar);
Handle(Geom2d_Curve) PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(anEdge.Reversed()),
theFace, fpar, lpar);
gp_Pnt2d Point1 = PCurve1->Value(fpar);
gp_Pnt2d Point2 = PCurve2->Value(fpar);
Standard_Boolean IsUiso = (Abs(Point1.X() - Point2.X()) > Abs(Point1.Y() - Point2.Y()));
if (IsUiso)
theUclosed = Standard_True;
if (IsSurfVclosed && !IsUiso)
else
theVclosed = Standard_True;
if (theUclosed && theVclosed)
break;
}
}
}

View File

@@ -73,31 +73,40 @@ public:
//purpose :
//=======================================================================
void BSplCLib::Hunt (const Array1OfReal& XX,
const Standard_Real X,
Standard_Integer& Ilc)
void BSplCLib::Hunt (const TColStd_Array1OfReal& theArray,
const Standard_Real theX,
Standard_Integer& theXPos)
{
// replaced by simple dichotomy (RLE)
Ilc = XX.Lower();
if (XX.Length() <= 1) return;
const Standard_Real *px = &XX(Ilc);
px -= Ilc;
if (X < px[Ilc]) {
Ilc--;
if (theArray.First() > theX)
{
theXPos = theArray.Lower() - 1;
return;
}
Standard_Integer Ihi = XX.Upper();
if (X > px[Ihi]) {
Ilc = Ihi + 1;
else if (theArray.Last() < theX)
{
theXPos = theArray.Upper() + 1;
return;
}
Standard_Integer Im;
while (Ihi - Ilc != 1) {
Im = (Ihi + Ilc) >> 1;
if (X > px[Im]) Ilc = Im;
else Ihi = Im;
theXPos = theArray.Lower();
if (theArray.Length() <= 1)
{
return;
}
Standard_Integer aHi = theArray.Upper();
while (aHi - theXPos != 1)
{
const Standard_Integer aMid = (aHi + theXPos) / 2;
if (theArray.Value (aMid) < theX)
{
theXPos = aMid;
}
else
{
aHi = aMid;
}
}
}

View File

@@ -124,23 +124,16 @@ public:
DEFINE_STANDARD_ALLOC
//! This routine searches the position of the real
//! value X in the ordered set of real values XX.
//! This routine searches the position of the real value theX
//! in the monotonically increasing set of real values theArray using bisection algorithm.
//!
//! The elements in the table XX are either
//! monotonically increasing or monotonically
//! decreasing.
//! If the given value is out of range or array values, algorithm returns either
//! theArray.Lower()-1 or theArray.Upper()+1 depending on theX position in the ordered set.
//!
//! The input value Iloc is used to initialize the
//! algorithm : if Iloc is outside of the bounds
//! [XX.Lower(), -- XX.Upper()] the bisection algorithm
//! is used else the routine searches from a previous
//! known position by increasing steps then converges
//! by bisection.
//!
//! This routine is used to locate a knot value in a
//! set of knots.
Standard_EXPORT static void Hunt (const TColStd_Array1OfReal& XX, const Standard_Real X, Standard_Integer& Iloc);
//! This routine is used to locate a knot value in a set of knots.
Standard_EXPORT static void Hunt (const TColStd_Array1OfReal& theArray,
const Standard_Real theX,
Standard_Integer& theXPos);
//! Computes the index of the knots value which gives
//! the start point of the curve.
@@ -1344,7 +1337,7 @@ public:
//! (3, NbPoles-2) -> the ends and the tangency are enforced
//! if Problem in BSplineBasis calculation, no change for the curve
//! and FirstIndex, LastIndex = 0
Standard_EXPORT static void MovePoint (const Standard_Real U, const gp_Vec2d& Displ, const Standard_Integer Index1, const Standard_Integer Index2, const Standard_Integer Degree, const Standard_Boolean Rational, const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Integer& FirstIndex, Standard_Integer& LastIndex, TColgp_Array1OfPnt2d& NewPoles);
Standard_EXPORT static void MovePoint (const Standard_Real U, const gp_Vec2d& Displ, const Standard_Integer Index1, const Standard_Integer Index2, const Standard_Integer Degree, const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Integer& FirstIndex, Standard_Integer& LastIndex, TColgp_Array1OfPnt2d& NewPoles);
//! Find the new poles which allows an old point (with a
//! given u as parameter) to reach a new position
@@ -1355,7 +1348,7 @@ public:
//! (3, NbPoles-2) -> the ends and the tangency are enforced
//! if Problem in BSplineBasis calculation, no change for the curve
//! and FirstIndex, LastIndex = 0
Standard_EXPORT static void MovePoint (const Standard_Real U, const gp_Vec& Displ, const Standard_Integer Index1, const Standard_Integer Index2, const Standard_Integer Degree, const Standard_Boolean Rational, const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Integer& FirstIndex, Standard_Integer& LastIndex, TColgp_Array1OfPnt& NewPoles);
Standard_EXPORT static void MovePoint (const Standard_Real U, const gp_Vec& Displ, const Standard_Integer Index1, const Standard_Integer Index2, const Standard_Integer Degree, const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Integer& FirstIndex, Standard_Integer& LastIndex, TColgp_Array1OfPnt& NewPoles);
//! This is the dimension free version of the utility
//! U is the parameter must be within the first FlatKnots and the
@@ -1373,7 +1366,7 @@ public:
//! = ...
//! Same holds for EndingCondition
//! Poles are the poles of the curve
//! Weights are the weights of the curve if Rational = Standard_True
//! Weights are the weights of the curve if not NULL
//! NewPoles are the poles of the deformed curve
//! ErrorStatus will be 0 if no error happened
//! 1 if there are not enough knots/poles
@@ -1382,7 +1375,7 @@ public:
//! If StartCondition = 1 and EndCondition = 1 then you need at least
//! 4 + 2 = 6 poles so for example to have a C1 cubic you will need
//! have at least 2 internal knots.
Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const Standard_Integer ArrayDimension, Standard_Real& Delta, Standard_Real& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Boolean Rational, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, Standard_Real& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Real& NewPoles, Standard_Integer& ErrorStatus);
Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const Standard_Integer ArrayDimension, Standard_Real& Delta, Standard_Real& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, Standard_Real& Poles, const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Real& NewPoles, Standard_Integer& ErrorStatus);
//! This is the dimension free version of the utility
//! U is the parameter must be within the first FlatKnots and the
@@ -1400,7 +1393,7 @@ public:
//! = ...
//! Same holds for EndingCondition
//! Poles are the poles of the curve
//! Weights are the weights of the curve if Rational = Standard_True
//! Weights are the weights of the curve if not NULL
//! NewPoles are the poles of the deformed curve
//! ErrorStatus will be 0 if no error happened
//! 1 if there are not enough knots/poles
@@ -1409,7 +1402,7 @@ public:
//! If StartCondition = 1 and EndCondition = 1 then you need at least
//! 4 + 2 = 6 poles so for example to have a C1 cubic you will need
//! have at least 2 internal knots.
Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const gp_Vec& Delta, const gp_Vec& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Boolean Rational, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& FlatKnots, TColgp_Array1OfPnt& NewPoles, Standard_Integer& ErrorStatus);
Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const gp_Vec& Delta, const gp_Vec& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, TColgp_Array1OfPnt& NewPoles, Standard_Integer& ErrorStatus);
//! This is the dimension free version of the utility
//! U is the parameter must be within the first FlatKnots and the
@@ -1427,7 +1420,7 @@ public:
//! = ...
//! Same holds for EndingCondition
//! Poles are the poles of the curve
//! Weights are the weights of the curve if Rational = Standard_True
//! Weights are the weights of the curve if not NULL
//! NewPoles are the poles of the deformed curve
//! ErrorStatus will be 0 if no error happened
//! 1 if there are not enough knots/poles
@@ -1436,7 +1429,7 @@ public:
//! If StartCondition = 1 and EndCondition = 1 then you need at least
//! 4 + 2 = 6 poles so for example to have a C1 cubic you will need
//! have at least 2 internal knots.
Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const gp_Vec2d& Delta, const gp_Vec2d& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Boolean Rational, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& FlatKnots, TColgp_Array1OfPnt2d& NewPoles, Standard_Integer& ErrorStatus);
Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const gp_Vec2d& Delta, const gp_Vec2d& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, TColgp_Array1OfPnt2d& NewPoles, Standard_Integer& ErrorStatus);
//! given a tolerance in 3D space returns a

View File

@@ -567,11 +567,10 @@ void BSplCLib::MovePointAndTangent(const Standard_Real U,
Standard_Real &DeltaDerivatives,
const Standard_Real Tolerance,
const Standard_Integer Degree,
const Standard_Boolean Rational,
const Standard_Integer StartingCondition,
const Standard_Integer EndingCondition,
Standard_Real& Poles,
const TColStd_Array1OfReal& Weights,
const TColStd_Array1OfReal* Weights,
const TColStd_Array1OfReal& FlatKnots,
Standard_Real& NewPoles,
Standard_Integer& ErrorStatus)
@@ -603,8 +602,8 @@ void BSplCLib::MovePointAndTangent(const Standard_Real U,
ErrorStatus = 0 ;
weights_array = NULL ;
if (Rational) {
weights_array = (Standard_Real *) &Weights(Weights.Lower()) ;
if (Weights != NULL) {
weights_array = const_cast<Standard_Real*>(&Weights->First());
}
poles_array = &Poles ;
@@ -765,7 +764,7 @@ void BSplCLib::MovePointAndTangent(const Standard_Real U,
extrap_mode[0] = Degree ;
extrap_mode[1] = Degree ;
if (Rational) {
if (Weights != NULL) {
//
// evaluate in homogenised form
//

View File

@@ -1218,9 +1218,8 @@ void BSplCLib::MovePoint (const Standard_Real U,
const Standard_Integer Index1,
const Standard_Integer Index2,
const Standard_Integer Degree,
const Standard_Boolean Rational,
const Array1OfPoints& Poles,
const TColStd_Array1OfReal& Weights,
const TColStd_Array1OfReal* Weights,
const TColStd_Array1OfReal& FlatKnots,
Standard_Integer& FirstIndex,
Standard_Integer& LastIndex,
@@ -1280,8 +1279,8 @@ void BSplCLib::MovePoint (const Standard_Real U,
for (i = 1; i <= Degree+1; i++) {
ii = i + FirstNonZeroBsplineIndex - 1;
if (Rational) {
hN = Weights(ii)*BSplineBasis(1, i);
if (Weights != NULL) {
hN = Weights->Value(ii)*BSplineBasis(1, i);
D2 += hN;
}
else {
@@ -1301,7 +1300,7 @@ void BSplCLib::MovePoint (const Standard_Real U,
}
}
if (Rational) {
if (Weights != NULL) {
Coef = D2/D1;
}
else {
@@ -1345,11 +1344,10 @@ void BSplCLib::MovePointAndTangent (const Standard_Real U,
const Vector& DeltaDerivatives,
const Standard_Real Tolerance,
const Standard_Integer Degree,
const Standard_Boolean Rational,
const Standard_Integer StartingCondition,
const Standard_Integer EndingCondition,
const Array1OfPoints& Poles,
const TColStd_Array1OfReal& Weights,
const TColStd_Array1OfReal* Weights,
const TColStd_Array1OfReal& FlatKnots,
Array1OfPoints& NewPoles,
Standard_Integer & ErrorStatus)
@@ -1376,7 +1374,6 @@ void BSplCLib::MovePointAndTangent (const Standard_Real U,
delta_derivative_array[0],
Tolerance,
Degree,
Rational,
StartingCondition,
EndingCondition,
poles_array[0],

View File

@@ -27,11 +27,14 @@
//function : ChFiDS_CommonPoint
//purpose :
//=======================================================================
ChFiDS_CommonPoint::ChFiDS_CommonPoint() :
tol(0.),
isonarc(Standard_False),
isvtx(Standard_False),
hasvector(Standard_False)
ChFiDS_CommonPoint::ChFiDS_CommonPoint()
: tol (0.0),
prmarc (0.0),
prmtg (0.0),
traarc (TopAbs_FORWARD),
isonarc(Standard_False),
isvtx (Standard_False),
hasvector (Standard_False)
{
}

View File

@@ -55,8 +55,12 @@ public:
//! Sets the values of a point which is a vertex on
//! the initial facet of restriction of one
//! of the surface.
void SetVertex (const TopoDS_Vertex& V);
void SetVertex (const TopoDS_Vertex& theVertex)
{
isvtx = Standard_True;
vtx = theVertex;
}
//! Sets the values of a point which is on the arc
//! A, at parameter Param.
Standard_EXPORT void SetArc (const Standard_Real Tol, const TopoDS_Edge& A, const Standard_Real Param, const TopAbs_Orientation TArc);
@@ -66,30 +70,44 @@ public:
//! Set the 3d point for a commonpoint that is not
//! a vertex or on an arc.
void SetPoint (const gp_Pnt& Point);
void SetPoint (const gp_Pnt& thePoint) { point = thePoint; }
//! Set the output 3d vector
void SetVector (const gp_Vec& Vector);
void SetVector (const gp_Vec& theVector)
{
hasvector = Standard_True;
vector = theVector;
}
//! This method set the fuzziness on the point.
void SetTolerance (const Standard_Real Tol);
void SetTolerance (const Standard_Real Tol)
{
if (Tol > tol)
{
tol = Tol;
}
}
//! This method returns the fuzziness on the point.
Standard_Real Tolerance() const;
Standard_Real Tolerance() const { return tol; }
//! Returns TRUE if the point is a vertex on the initial
//! restriction facet of the surface.
Standard_Boolean IsVertex() const;
Standard_Boolean IsVertex() const { return isvtx; }
//! Returns the information about the point when it is
//! on the domain of the first patch, i-e when the function
//! IsVertex returns True.
//! Otherwise, an exception is raised.
const TopoDS_Vertex& Vertex() const;
const TopoDS_Vertex& Vertex() const
{
if (!isvtx) { throw Standard_DomainError(); }
return vtx;
}
//! Returns TRUE if the point is a on an edge of the initial
//! restriction facet of the surface.
Standard_Boolean IsOnArc() const;
Standard_Boolean IsOnArc() const { return isonarc; }
//! Returns the arc of restriction containing the
//! vertex.
@@ -107,27 +125,20 @@ public:
Standard_EXPORT Standard_Real Parameter() const;
//! Returns the 3d point
const gp_Pnt& Point() const;
const gp_Pnt& Point() const { return point; }
//! Returns TRUE if the output vector is stored.
Standard_Boolean HasVector() const;
Standard_Boolean HasVector() const { return hasvector; }
//! Returns the output 3d vector
const gp_Vec& Vector() const;
protected:
const gp_Vec& Vector() const
{
if (!hasvector) { throw Standard_DomainError ("ChFiDS_CommonPoint::Vector"); }
return vector;
}
private:
TopoDS_Edge arc;
TopoDS_Vertex vtx;
gp_Pnt point;
@@ -135,19 +146,11 @@ private:
Standard_Real tol;
Standard_Real prmarc;
Standard_Real prmtg;
Standard_Boolean isonarc;
TopAbs_Orientation traarc;
Standard_Boolean isonarc;
Standard_Boolean isvtx;
Standard_Boolean hasvector;
};
#include <ChFiDS_CommonPoint.lxx>
#endif // _ChFiDS_CommonPoint_HeaderFile

View File

@@ -1,140 +0,0 @@
// Created on: 1993-11-30
// Created by: Isabelle GRIGNON
// Copyright (c) 1993-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.
//=======================================================================
//function : SetVertex
//purpose :
//=======================================================================
inline void ChFiDS_CommonPoint::SetVertex(const TopoDS_Vertex& V)
{
isvtx = Standard_True;
vtx = V;
}
//=======================================================================
//function : SetPoint
//purpose :
//=======================================================================
inline void ChFiDS_CommonPoint::SetPoint(const gp_Pnt& Point)
{
point = Point;
}
//=======================================================================
//function : SetVector
//purpose :
//=======================================================================
inline void ChFiDS_CommonPoint::SetVector(const gp_Vec& Vector)
{
hasvector = Standard_True;
vector = Vector;
}
//=======================================================================
//function : SetTolerance
//purpose :
// PMN : 30/09/1997 : On se contente d'updater la tolerance.
//=======================================================================
inline void ChFiDS_CommonPoint::SetTolerance(const Standard_Real Tol)
{
if (Tol>tol) tol = Tol;
}
//=======================================================================
//function : Tolerance
//purpose :
//=======================================================================
inline Standard_Real ChFiDS_CommonPoint::Tolerance()const
{
return tol;
}
//=======================================================================
//function : IsVertex
//purpose :
//=======================================================================
inline Standard_Boolean ChFiDS_CommonPoint::IsVertex()const
{
return isvtx;
}
//=======================================================================
//function : Vertex
//purpose :
//=======================================================================
inline const TopoDS_Vertex& ChFiDS_CommonPoint::Vertex()const
{
if (!isvtx) {throw Standard_DomainError();}
return vtx;
}
//=======================================================================
//function : Point
//purpose :
//=======================================================================
inline const gp_Pnt& ChFiDS_CommonPoint::Point()const
{
return point;
}
//=======================================================================
//function : HasVector
//purpose :
//=======================================================================
inline Standard_Boolean ChFiDS_CommonPoint::HasVector()const
{
return hasvector;
}
//=======================================================================
//function : Vector
//purpose :
//=======================================================================
inline const gp_Vec& ChFiDS_CommonPoint::Vector()const
{
if (!hasvector) {
throw Standard_DomainError("ChFiDS_CommonPoint::Vector");
}
return vector;
}
//=======================================================================
//function : IsOnArc
//purpose :
//=======================================================================
inline Standard_Boolean ChFiDS_CommonPoint::IsOnArc()const
{
return isonarc;
}

View File

@@ -6,7 +6,6 @@ ChFiDS_CircSection.cxx
ChFiDS_CircSection.hxx
ChFiDS_CommonPoint.cxx
ChFiDS_CommonPoint.hxx
ChFiDS_CommonPoint.lxx
ChFiDS_ElSpine.cxx
ChFiDS_ElSpine.hxx
ChFiDS_ErrorStatus.hxx

View File

@@ -480,15 +480,31 @@ static unsigned int __stdcall CpuFunc (void * /*param*/)
if (CPU_LIMIT > 0 && (aCurrent - CPU_CURRENT) >= CPU_LIMIT)
{
cout << "Process killed by CPU limit (" << CPU_LIMIT << " sec)" << endl;
aTimer.Stop();
ExitProcess (2);
if (IsDebuggerPresent())
{
std::cout << "ERROR: CPU limit (" << CPU_LIMIT << " sec) has been reached but ignored because of attached Debugger" << std::endl;
return 0;
}
else
{
std::cout << "ERROR: Process killed by CPU limit (" << CPU_LIMIT << " sec)" << std::endl;
ExitProcess (2);
}
}
if (CPU_LIMIT > 0 && anElapCurrent >= CPU_LIMIT)
{
cout << "Process killed by elapsed limit (" << CPU_LIMIT << " sec)" << endl;
aTimer.Stop();
ExitProcess (2);
if (IsDebuggerPresent())
{
std::cout << "ERROR: Elapsed limit (" << CPU_LIMIT << " sec) has been reached but ignored because of attached Debugger" << std::endl;
return 0;
}
else
{
std::cout << "ERROR: Process killed by elapsed limit (" << CPU_LIMIT << " sec)" << std::endl;
ExitProcess (2);
}
}
}
}

View File

@@ -718,6 +718,7 @@ help testdiff {
Compare results of two executions of tests (CPU times, ...)
Use: testdiff dir1 dir2 [groupname [gridname]] [options...]
Where dir1 and dir2 are directories containing logs of two test runs.
dir1 (A) should point to NEW tests results to be verified and dir2 (B) to REFERENCE results.
Allowed options are:
-image [filename]: compare only images and save its in specified file (default
name is <dir1>/diffimage-<dir2>.log)
@@ -2215,6 +2216,8 @@ proc _test_diff {dir1 dir2 basename image cpu memory status verbose _logvar _log
# check images
if {$image != false || ($image == false && $cpu == false && $memory == false)} {
set aCaseDiffColorTol 0
if { [regexp {IMAGE_COLOR_TOLERANCE:\s*([\d.]+)} $log1 res1 imgtol1] } { set aCaseDiffColorTol $imgtol1 }
set imglist1 [glob -directory $path1 -types f -tails -nocomplain ${casename}.{png,gif} ${casename}-*.{png,gif} ${casename}_*.{png,gif}]
set imglist2 [glob -directory $path2 -types f -tails -nocomplain ${casename}.{png,gif} ${casename}-*.{png,gif} ${casename}_*.{png,gif}]
_list_diff $imglist1 $imglist2 imgin1 imgin2 imgcommon
@@ -2239,7 +2242,7 @@ proc _test_diff {dir1 dir2 basename image cpu memory status verbose _logvar _log
set diffile [_diff_img_name $dir1 $dir2 $basename $imgfile]
if { [catch {diffimage [file join $dir1 $basename $imgfile] \
[file join $dir2 $basename $imgfile] \
0 0 0 $diffile} diff] } {
-toleranceOfColor 0.0 -blackWhite off -borderFilter off $diffile} diff] } {
if {$image != false} {
_log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile cannot be compared"
} else {
@@ -2247,10 +2250,35 @@ proc _test_diff {dir1 dir2 basename image cpu memory status verbose _logvar _log
}
file delete -force $diffile ;# clean possible previous result of diffimage
} elseif { $diff != 0 } {
set diff [string trimright $diff \n]
if {$aCaseDiffColorTol != 0} {
# retry with color tolerance
if { [catch {diffimage [file join $dir1 $basename $imgfile] \
[file join $dir2 $basename $imgfile] \
-toleranceOfColor $aCaseDiffColorTol -blackWhite off -borderFilter off $diffile} diff2] } {
if {$image != false} {
_log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile cannot be compared"
} else {
_log_and_puts log "IMAGE [split $basename /] $casename: $imgfile cannot be compared"
}
continue
} elseif { $diff2 == 0 } {
# exclude image diff within tolerance but still keep info in the log
set toLogImageCase false
file delete -force $diffile
if {$image != false} {
_log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile is similar \[$diff different pixels\]"
} else {
_log_and_puts log "IMAGE [split $basename /] $casename: $imgfile is similar \[$diff different pixels\]"
}
continue
}
}
if {$image != false} {
_log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile differs"
_log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile differs \[$diff different pixels\]"
} else {
_log_and_puts log "IMAGE [split $basename /] $casename: $imgfile differs"
_log_and_puts log "IMAGE [split $basename /] $casename: $imgfile differs \[$diff different pixels\]"
}
} else {
file delete -force $diffile ;# clean useless artifact of diffimage
@@ -2311,8 +2339,8 @@ proc _log_html_diff {file log dir1 dir2 highlight_percent} {
# print header
puts $fd "<html><head><title>Diff $dir1 vs. $dir2</title></head><body>"
puts $fd "<h1>Comparison of test results:</h1>"
puts $fd "<h2>Version A - $dir1</h2>"
puts $fd "<h2>Version B - $dir2</h2>"
puts $fd "<h2>Version A \[NEW\] - $dir1</h2>"
puts $fd "<h2>Version B \[REF\] - $dir2</h2>"
# add script for switching between images on click
puts $fd ""
@@ -2334,12 +2362,16 @@ proc _log_html_diff {file log dir1 dir2 highlight_percent} {
if { [regexp "\[\\\[](\[0-9.e+-]+)%\[\]]" $line res value] &&
[expr abs($value)] > ${highlight_percent} } {
puts $fd "<table><tr><td bgcolor=\"[expr $value > 0 ? \"ff8080\" : \"lightgreen\"]\">$line</td></tr></table>"
} else {
} elseif { [regexp {IMAGE[ \t]+([^:]+):[ \t]+([A-Za-z0-9_.-]+) is similar} $line res case img] } {
if { [catch {eval file join "" [lrange $case 0 end-1]} gridpath] } {
# note: special handler for the case if test grid directoried are compared directly
set gridpath ""
}
set aCaseName [lindex $case end]
puts $fd "<table><tr><td bgcolor=\"orange\"><a href=\"[_make_url $file [file join $dir1 $gridpath $aCaseName.html]]\">$line</a></td></tr></table>"
} elseif { [regexp {IMAGE[ \t]+([^:]+):[ \t]+([A-Za-z0-9_.-]+)} $line res case img] } {
# add images
puts $fd $line
}
# add images
if { [regexp {IMAGE[ \t]+([^:]+):[ \t]+([A-Za-z0-9_.-]+)} $line res case img] } {
if { [catch {eval file join "" [lrange $case 0 end-1]} gridpath] } {
# note: special handler for the case if test grid directoried are compared directly
set gridpath ""
@@ -2360,6 +2392,8 @@ proc _log_html_diff {file log dir1 dir2 highlight_percent} {
puts $fd "<table><tr><th><abbr title=\"$dir1\">Version A</abbr></th><th><abbr title=\"$dir2\">Version B</abbr></th><th>Diff (click to toggle)</th></tr>"
puts $fd "<tr><td>$img1</td><td>$img2</td><td>$imgd</td></tr></table>"
} else {
puts $fd $line
}
}
puts $fd "</pre></body></html>"

View File

@@ -67,7 +67,7 @@ Standard_Boolean Expr_NamedExpression::IsIdentical
//AGV 22.03.12: Comparison should be based on names rather than Handles
const Expr_NamedExpression* pOther =
static_cast<const Expr_NamedExpression*>(theOther.operator->());
static_cast<const Expr_NamedExpression*>(theOther.get());
if (pOther == this || pOther->GetName().IsEqual(myName))
aResult = Standard_True;
}

View File

@@ -215,7 +215,9 @@ static Standard_Boolean PerformComposite (TColStd_SequenceOfReal& Parameters,
Standard_Real Ua = U1;
for (Standard_Integer Index = PIndex;;)
{
Standard_Real Ub = Min (U2, TI (Index + 1));
Standard_Real Ub = Index + 1 <= TI.Upper()
? Min (U2, TI (Index + 1))
: U2;
if (!PerformCurve (Parameters, Points, C, Deflection,
Ua, Ub, EPSILON, Continuity))
return Standard_False;

View File

@@ -174,7 +174,9 @@ static Standard_Boolean PerformComposite (TColStd_SequenceOfReal& Parameters,
Standard_Real Ua = U1;
for (Standard_Integer Index = PIndex;;)
{
Standard_Real Ub = Min (U2, TI (Index + 1));
Standard_Real Ub = Index + 1 <= TI.Upper()
? Min (U2, TI (Index + 1))
: U2;
if (!PerformCurve (Parameters, Points, C, Deflection,
Ua, Ub, EPSILON, WithControl))
{

View File

@@ -257,35 +257,21 @@ void Geom_BSplineCurve::IncreaseDegree (const Standard_Integer Degree)
new TColStd_HArray1OfInteger(1,nbknots);
Handle(TColStd_HArray1OfReal) nweights;
if (IsRational()) {
if (IsRational())
{
nweights = new TColStd_HArray1OfReal(1,npoles->Upper());
BSplCLib::IncreaseDegree
(deg,Degree, periodic,
poles->Array1(),&weights->Array1(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(),&nweights->ChangeArray1(),
nknots->ChangeArray1(),nmults->ChangeArray1());
}
else {
BSplCLib::IncreaseDegree
(deg,Degree, periodic,
poles->Array1(),BSplCLib::NoWeights(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1());
}
BSplCLib::IncreaseDegree (deg, Degree, periodic,
poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), mults->Array1(),
npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1());
deg = Degree;
poles = npoles;
weights = nweights;
knots = nknots;
mults = nmults;
UpdateKnots();
}
//=======================================================================
@@ -385,34 +371,24 @@ void Geom_BSplineCurve::InsertKnots(const TColStd_Array1OfReal& Knots,
nmults = new TColStd_HArray1OfInteger(1,nbknots);
}
if (rational) {
Handle(TColStd_HArray1OfReal) nweights =
new TColStd_HArray1OfReal(1,nbpoles);
BSplCLib::InsertKnots(deg,periodic,
poles->Array1(), &weights->Array1(),
knots->Array1(), mults->Array1(),
Knots, &Mults,
npoles->ChangeArray1(), &nweights->ChangeArray1(),
nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon, Add);
weights = nweights;
}
else {
BSplCLib::InsertKnots(deg,periodic,
poles->Array1(), BSplCLib::NoWeights(),
knots->Array1(), mults->Array1(),
Knots, &Mults,
npoles->ChangeArray1(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon, Add);
Handle(TColStd_HArray1OfReal) nweights;
if (rational)
{
nweights = new TColStd_HArray1OfReal(1,nbpoles);
}
BSplCLib::InsertKnots (deg, periodic,
poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), mults->Array1(),
Knots, &Mults,
npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon, Add);
weights = nweights;
poles = npoles;
knots = nknots;
mults = nmults;
UpdateKnots();
}
//=======================================================================
@@ -452,31 +428,23 @@ Standard_Boolean Geom_BSplineCurve::RemoveKnot(const Standard_Integer Index,
nmults = new TColStd_HArray1OfInteger(1,knots->Length()-1);
}
if (IsRational()) {
Handle(TColStd_HArray1OfReal) nweights =
new TColStd_HArray1OfReal(1,npoles->Length());
if (!BSplCLib::RemoveKnot
(Index, M, deg, periodic,
poles->Array1(),&weights->Array1(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(), &nweights->ChangeArray1(),
nknots->ChangeArray1(),nmults->ChangeArray1(),
Tolerance))
return Standard_False;
weights = nweights;
Handle(TColStd_HArray1OfReal) nweights;
if (IsRational())
{
nweights = new TColStd_HArray1OfReal(1,npoles->Length());
}
else {
if (!BSplCLib::RemoveKnot
(Index, M, deg, periodic,
poles->Array1(), BSplCLib::NoWeights(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1(),
Tolerance))
return Standard_False;
if (!BSplCLib::RemoveKnot (Index, M, deg, periodic,
poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1(),
Tolerance))
{
return Standard_False;
}
weights = nweights;
poles = npoles;
knots = nknots;
mults = nmults;
@@ -932,27 +900,16 @@ void Geom_BSplineCurve::SetNotPeriodic ()
= new TColStd_HArray1OfInteger(1,NbKnots);
Handle(TColStd_HArray1OfReal) nweights;
if (IsRational()) {
if (IsRational())
{
nweights = new TColStd_HArray1OfReal(1,NbPoles);
BSplCLib::Unperiodize
(deg,mults->Array1(),knots->Array1(),poles->Array1(),
&weights->Array1(),nmults->ChangeArray1(),
nknots->ChangeArray1(),npoles->ChangeArray1(),
&nweights->ChangeArray1());
}
else {
BSplCLib::Unperiodize
(deg,mults->Array1(),knots->Array1(),poles->Array1(),
BSplCLib::NoWeights(),nmults->ChangeArray1(),
nknots->ChangeArray1(),npoles->ChangeArray1(),
BSplCLib::NoWeights());
}
BSplCLib::Unperiodize (deg,
mults->Array1(), knots->Array1(), poles->Array1(),
!nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
nmults->ChangeArray1(), nknots->ChangeArray1(), npoles->ChangeArray1(),
!nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights());
poles = npoles;
weights = nweights;
mults = nmults;
@@ -1046,9 +1003,9 @@ void Geom_BSplineCurve::MovePoint(const Standard_Real U,
gp_Pnt P0;
D0(U, P0);
gp_Vec Displ(P0, P);
BSplCLib::MovePoint(U, Displ, Index1, Index2, deg, rational, poles->Array1(),
weights->Array1(), flatknots->Array1(),
FirstModifiedPole, LastmodifiedPole, npoles);
BSplCLib::MovePoint (U, Displ, Index1, Index2, deg, poles->Array1(),
rational ? &weights->Array1() : BSplCLib::NoWeights(), flatknots->Array1(),
FirstModifiedPole, LastmodifiedPole, npoles);
if (FirstModifiedPole) {
poles->ChangeArray1() = npoles;
maxderivinvok = 0;
@@ -1091,11 +1048,10 @@ void Geom_BSplineCurve::MovePointAndTangent(const Standard_Real U,
delta_derivative,
Tolerance,
deg,
rational,
StartingCondition,
EndingCondition,
poles->Array1(),
weights->Array1(),
rational ? &weights->Array1() : BSplCLib::NoWeights(),
flatknots->Array1(),
new_poles,
ErrorStatus) ;

View File

@@ -14,14 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// 03-02-97 : pmn ->LocateU sur Periodic (PRO6963),
// bon appel a LocateParameter (PRO6973) et mise en conformite avec
// le cdl de LocateU, lorsque U est un noeud (PRO6988)
#define No_Standard_OutOfRange
#define No_Standard_DimensionError
#include <BSplCLib.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Geometry.hxx>
@@ -192,20 +184,11 @@ void Geom_BSplineCurve::D0(const Standard_Real U, gp_Pnt& P) const
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES,
&weights->Array1(),
knots->Array1(), &mults->Array1(),
P);
}
else
{
BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P);
}
BSplCLib::D0 (aNewU, aSpanIndex, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P);
}
//=======================================================================
@@ -223,20 +206,11 @@ void Geom_BSplineCurve::D1 (const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES,
&weights->Array1(),
knots->Array1(), &mults->Array1(),
P, V1);
}
else
{
BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1);
}
BSplCLib::D1 (aNewU, aSpanIndex, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1);
}
//=======================================================================
@@ -255,20 +229,11 @@ void Geom_BSplineCurve::D2(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES,
&weights->Array1(),
knots->Array1(), &mults->Array1(),
P, V1, V2);
}
else
{
BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2);
}
BSplCLib::D2 (aNewU, aSpanIndex, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2);
}
//=======================================================================
@@ -288,20 +253,11 @@ void Geom_BSplineCurve::D3(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES,
&weights->Array1(),
knots->Array1(), &mults->Array1(),
P, V1, V2, V3);
}
else
{
BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2, V3);
}
BSplCLib::D3 (aNewU, aSpanIndex, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2, V3);
}
//=======================================================================
@@ -313,16 +269,9 @@ gp_Vec Geom_BSplineCurve::DN(const Standard_Real U,
const Standard_Integer N) const
{
gp_Vec V;
if (rational) {
BSplCLib::DN(U,N,0,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,V);
}
else {
BSplCLib::DN(U,N,0,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,V);
}
BSplCLib::DN (U, N, 0, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, V);
return V;
}
@@ -474,16 +423,9 @@ void Geom_BSplineCurve::LocalD0
Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic,FromK1,ToK2, index,u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) {
BSplCLib::D0(u,index,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,P);
}
else {
BSplCLib::D0(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P);
}
BSplCLib::D0 (u, index, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, P);
}
//=======================================================================
@@ -504,16 +446,9 @@ void Geom_BSplineCurve::LocalD1 (const Standard_Real U,
Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) {
BSplCLib::D1(u,index,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,P,V1);
}
else {
BSplCLib::D1(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1);
}
BSplCLib::D1 (u, index, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1);
}
//=======================================================================
@@ -536,16 +471,9 @@ void Geom_BSplineCurve::LocalD2
Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) {
BSplCLib::D2(u,index,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,P,V1,V2);
}
else {
BSplCLib::D2(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1,V2);
}
BSplCLib::D2 (u, index, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, P, V1, V2);
}
//=======================================================================
@@ -569,16 +497,9 @@ void Geom_BSplineCurve::LocalD3
Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) {
BSplCLib::D3(u,index,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,P,V1,V2,V3);
}
else {
BSplCLib::D3(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1,V2,V3);
}
BSplCLib::D3 (u, index, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, P, V1, V2, V3);
}
//=======================================================================
@@ -601,16 +522,9 @@ gp_Vec Geom_BSplineCurve::LocalDN
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
gp_Vec V;
if (rational) {
BSplCLib::DN(u,N,index,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,V);
}
else {
BSplCLib::DN(u,N,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,V);
}
BSplCLib::DN (u, N, index, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, V);
return V;
}
@@ -809,7 +723,12 @@ void Geom_BSplineCurve::LocateU
else {
I1 = 1;
BSplCLib::Hunt (CKnots, NewU, I1);
while ( Abs( CKnots(I1+1) - NewU) <= PParametricTolerance) I1++;
I1 = Max (Min (I1, CKnots.Upper()), CKnots.Lower());
while (I1 + 1 <= CKnots.Upper()
&& Abs (CKnots (I1 + 1) - NewU) <= PParametricTolerance)
{
I1++;
}
if ( Abs( CKnots(I1) - NewU) <= PParametricTolerance) {
I2 = I1;
}
@@ -824,64 +743,45 @@ void Geom_BSplineCurve::LocateU
//purpose :
//=======================================================================
void Geom_BSplineCurve::Resolution(const Standard_Real Tolerance3D,
Standard_Real & UTolerance)
void Geom_BSplineCurve::Resolution (const Standard_Real Tolerance3D,
Standard_Real& UTolerance)
{
Standard_Integer ii;
if(!maxderivinvok){
if ( periodic) {
if (!maxderivinvok)
{
if (periodic)
{
Standard_Integer NbKnots, NbPoles;
BSplCLib::PrepareUnperiodize( deg,
mults->Array1(),
NbKnots,
NbPoles);
TColgp_Array1OfPnt new_poles(1,NbPoles) ;
TColStd_Array1OfReal new_weights(1,NbPoles) ;
for(ii = 1 ; ii <= NbPoles ; ii++) {
new_poles(ii) = poles->Array1()((ii-1) % poles->Length() + 1) ;
BSplCLib::PrepareUnperiodize (deg, mults->Array1(), NbKnots, NbPoles);
TColgp_Array1OfPnt new_poles (1, NbPoles);
TColStd_Array1OfReal new_weights(1, NbPoles);
for (Standard_Integer ii = 1; ii <= NbPoles; ii++)
{
new_poles(ii) = poles->Array1()((ii-1) % poles->Length() + 1);
}
if (rational) {
for(ii = 1 ; ii <= NbPoles ; ii++) {
new_weights(ii) = weights->Array1()((ii-1) % poles->Length() + 1) ;
}
BSplCLib::Resolution(new_poles,
&new_weights,
new_poles.Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
if (rational)
{
for (Standard_Integer ii = 1; ii <= NbPoles; ii++)
{
new_weights(ii) = weights->Array1()((ii-1) % poles->Length() + 1);
}
}
else {
BSplCLib::Resolution(new_poles,
BSplCLib::NoWeights(),
new_poles.Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
BSplCLib::Resolution (new_poles,
rational ? &new_weights : BSplCLib::NoWeights(),
new_poles.Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv);
}
else {
if (rational) {
BSplCLib::Resolution(poles->Array1(),
&weights->Array1(),
poles->Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
else {
BSplCLib::Resolution(poles->Array1(),
BSplCLib::NoWeights(),
poles->Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
else
{
BSplCLib::Resolution (poles->Array1(),
rational ? &weights->Array1() : BSplCLib::NoWeights(),
poles->Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv);
}
maxderivinvok = 1;
}

View File

@@ -23,10 +23,6 @@
// + bon appel a LocateParameter (PRO6973).
// RBD : 15/10/98 ; Le cache est desormais defini sur [-1,1] (pro15537).
#define No_Standard_OutOfRange
#define No_Standard_DimensionError
#include <BSplCLib.hxx>
#include <BSplSLib.hxx>
#include <Geom_BSplineCurve.hxx>
@@ -1360,7 +1356,12 @@ void Geom_BSplineSurface::LocateU
else {
I1 = 1;
BSplCLib::Hunt (Knots, NewU, I1);
while ( Abs( Knots(I1+1) - NewU) <= PParametricTolerance) I1++;
I1 = Max (Min (I1, Knots.Upper()), Knots.Lower());
while (I1 + 1 <= Knots.Upper()
&& Abs (Knots (I1 + 1) - NewU) <= PParametricTolerance)
{
I1++;
}
if ( Abs( Knots(I1) - NewU) <= PParametricTolerance) {
I2 = I1;
}
@@ -1408,7 +1409,12 @@ void Geom_BSplineSurface::LocateV
else {
I1 = 1;
BSplCLib::Hunt (Knots, NewV, I1);
while ( Abs( Knots(I1+1) - NewV) <= PParametricTolerance) I1++;
I1 = Max (Min (I1, Knots.Upper()), Knots.Lower());
while (I1 + 1 <= Knots.Upper()
&& Abs (Knots (I1 + 1) - NewV) <= PParametricTolerance)
{
I1++;
}
if ( Abs( Knots(I1) - NewV) <= PParametricTolerance) {
I2 = I1;
}

View File

@@ -257,27 +257,14 @@ void Geom2d_BSplineCurve::IncreaseDegree
Handle(TColStd_HArray1OfReal) nweights;
if (IsRational()) {
nweights = new TColStd_HArray1OfReal(1,npoles->Upper());
BSplCLib::IncreaseDegree
(deg,Degree, periodic,
poles->Array1(),&weights->Array1(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(),&nweights->ChangeArray1(),
nknots->ChangeArray1(),nmults->ChangeArray1());
}
else {
BSplCLib::IncreaseDegree
(deg,Degree, periodic,
poles->Array1(),
BSplCLib::NoWeights(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1());
}
BSplCLib::IncreaseDegree (deg, Degree, periodic,
poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), mults->Array1(),
npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
nknots->ChangeArray1(), nmults->ChangeArray1());
deg = Degree;
poles = npoles;
@@ -384,35 +371,24 @@ void Geom2d_BSplineCurve::InsertKnots(const TColStd_Array1OfReal& Knots,
nmults = new TColStd_HArray1OfInteger(1,nbknots);
}
if (rational) {
Handle(TColStd_HArray1OfReal) nweights =
new TColStd_HArray1OfReal(1,nbpoles);
BSplCLib::InsertKnots(deg,periodic,
poles->Array1(), &weights->Array1(),
knots->Array1(), mults->Array1(),
Knots, &Mults,
npoles->ChangeArray1(), &nweights->ChangeArray1(),
nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon,Add);
weights = nweights;
}
else {
BSplCLib::InsertKnots(deg,periodic,
poles->Array1(),
BSplCLib::NoWeights(),
knots->Array1(), mults->Array1(),
Knots, &Mults,
npoles->ChangeArray1(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon,Add);
Handle(TColStd_HArray1OfReal) nweights;
if (rational)
{
nweights = new TColStd_HArray1OfReal (1, nbpoles);
}
BSplCLib::InsertKnots (deg, periodic,
poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), mults->Array1(),
Knots, &Mults,
npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon, Add);
weights = nweights;
poles = npoles;
knots = nknots;
mults = nmults;
UpdateKnots();
}
//=======================================================================
@@ -450,32 +426,23 @@ Standard_Boolean Geom2d_BSplineCurve::RemoveKnot
nmults = new TColStd_HArray1OfInteger(1,knots->Length()-1);
}
if (IsRational()) {
Handle(TColStd_HArray1OfReal) nweights =
new TColStd_HArray1OfReal(1,npoles->Length());
if (!BSplCLib::RemoveKnot
(Index, M, deg, periodic,
poles->Array1(),&weights->Array1(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(), &nweights->ChangeArray1(),
nknots->ChangeArray1(),nmults->ChangeArray1(),
Tolerance))
return Standard_False;
weights = nweights;
Handle(TColStd_HArray1OfReal) nweights;
if (IsRational())
{
nweights = new TColStd_HArray1OfReal(1,npoles->Length());
}
else {
if (!BSplCLib::RemoveKnot
(Index, M, deg, periodic,
poles->Array1(),
BSplCLib::NoWeights(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1(),
Tolerance))
return Standard_False;
if (!BSplCLib::RemoveKnot (Index, M, deg, periodic,
poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1(),
Tolerance))
{
return Standard_False;
}
weights = nweights;
poles = npoles;
knots = nknots;
mults = nmults;
@@ -1047,27 +1014,15 @@ void Geom2d_BSplineCurve::SetNotPeriodic ()
= new TColStd_HArray1OfInteger(1,NbKnots);
Handle(TColStd_HArray1OfReal) nweights;
if (IsRational()) {
nweights = new TColStd_HArray1OfReal(1,NbPoles);
BSplCLib::Unperiodize
(deg,mults->Array1(),knots->Array1(),poles->Array1(),
&weights->Array1(),nmults->ChangeArray1(),
nknots->ChangeArray1(),npoles->ChangeArray1(),
&nweights->ChangeArray1());
}
else {
BSplCLib::Unperiodize
(deg,mults->Array1(),knots->Array1(),poles->Array1(),
BSplCLib::NoWeights(),nmults->ChangeArray1(),
nknots->ChangeArray1(),npoles->ChangeArray1(),
BSplCLib::NoWeights());
}
BSplCLib::Unperiodize (deg,
mults->Array1(), knots->Array1(), poles->Array1(),
!nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
nmults->ChangeArray1(), nknots->ChangeArray1(), npoles->ChangeArray1(),
!nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights());
poles = npoles;
weights = nweights;
mults = nmults;
@@ -1161,9 +1116,10 @@ void Geom2d_BSplineCurve::MovePoint(const Standard_Real U,
gp_Pnt2d P0;
D0(U, P0);
gp_Vec2d Displ(P0, P);
BSplCLib::MovePoint(U, Displ, Index1, Index2, deg, rational, poles->Array1(),
weights->Array1(), flatknots->Array1(),
FirstModifiedPole, LastmodifiedPole, npoles);
BSplCLib::MovePoint (U, Displ, Index1, Index2, deg, poles->Array1(),
rational ? &weights->Array1() : BSplCLib::NoWeights(), flatknots->Array1(),
FirstModifiedPole, LastmodifiedPole, npoles);
if (FirstModifiedPole) {
poles->ChangeArray1() = npoles;
maxderivinvok = 0;
@@ -1203,19 +1159,19 @@ MovePointAndTangent(const Standard_Real U,
delta_derivative.SetCoord(ii,
Tangent.Coord(ii)- delta_derivative.Coord(ii)) ;
}
BSplCLib::MovePointAndTangent(U,
delta,
delta_derivative,
Tolerance,
deg,
rational,
StartingCondition,
EndingCondition,
poles->Array1(),
weights->Array1(),
flatknots->Array1(),
new_poles,
ErrorStatus) ;
BSplCLib::MovePointAndTangent (U,
delta,
delta_derivative,
Tolerance,
deg,
StartingCondition,
EndingCondition,
poles->Array1(),
rational ? &weights->Array1() : BSplCLib::NoWeights(),
flatknots->Array1(),
new_poles,
ErrorStatus);
if (!ErrorStatus) {
poles->ChangeArray1() = new_poles;
maxderivinvok = 0;

View File

@@ -14,14 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// 03-02-97 : pmn ->LocateU sur Periodic (PRO6963),
// bon appel a LocateParameter (PRO6973) et mise en conformite avec
// le cdl de LocateU, lorsque U est un noeud (PRO6988)
#define No_Standard_OutOfRange
#define No_Standard_DimensionError
#include <BSplCLib.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_Geometry.hxx>
@@ -198,20 +190,11 @@ void Geom2d_BSplineCurve::D0(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES,
&weights->Array1(),
knots->Array1(), &mults->Array1(),
P);
}
else
{
BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P);
}
BSplCLib::D0 (aNewU, aSpanIndex, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P);
}
@@ -230,20 +213,11 @@ void Geom2d_BSplineCurve::D1(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES,
&weights->Array1(),
knots->Array1(), &mults->Array1(),
P, V1);
}
else
{
BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1);
}
BSplCLib::D1 (aNewU, aSpanIndex, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1);
}
//=======================================================================
@@ -262,20 +236,11 @@ void Geom2d_BSplineCurve::D2(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES,
&weights->Array1(),
knots->Array1(), &mults->Array1(),
P, V1, V2);
}
else
{
BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2);
}
BSplCLib::D2 (aNewU, aSpanIndex, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2);
}
//=======================================================================
@@ -295,20 +260,11 @@ void Geom2d_BSplineCurve::D3(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES,
&weights->Array1(),
knots->Array1(), &mults->Array1(),
P, V1, V2, V3);
}
else
{
BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2, V3);
}
BSplCLib::D3 (aNewU, aSpanIndex, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2, V3);
}
//=======================================================================
@@ -320,17 +276,9 @@ gp_Vec2d Geom2d_BSplineCurve::DN(const Standard_Real U,
const Standard_Integer N) const
{
gp_Vec2d V;
if ( rational ) {
BSplCLib::DN(U,N,0,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS, V);
}
else {
BSplCLib::DN(U,N,0,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,V);
}
BSplCLib::DN (U, N, 0, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, V);
return V;
}
@@ -483,16 +431,9 @@ void Geom2d_BSplineCurve::LocalD0
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic,FromK1,ToK2, index,u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if ( rational ) {
BSplCLib::D0(u,index,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,P);
}
else {
BSplCLib::D0(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P);
}
BSplCLib::D0 (u, index, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, P);
}
//=======================================================================
@@ -514,16 +455,9 @@ void Geom2d_BSplineCurve::LocalD1 (const Standard_Real U,
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) {
BSplCLib::D1(u,index,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,P,V1);
}
else {
BSplCLib::D1(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1);
}
BSplCLib::D1 (u, index, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, P, V1);
}
//=======================================================================
@@ -547,16 +481,9 @@ void Geom2d_BSplineCurve::LocalD2
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if ( rational ) {
BSplCLib::D2(u,index,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,P,V1,V2);
}
else {
BSplCLib::D2(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1,V2);
}
BSplCLib::D2 (u, index, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, P, V1, V2);
}
//=======================================================================
@@ -581,16 +508,9 @@ void Geom2d_BSplineCurve::LocalD3
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if ( rational ) {
BSplCLib::D3(u,index,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,P,V1,V2,V3);
}
else {
BSplCLib::D3(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1,V2,V3);
}
BSplCLib::D3 (u, index, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, P, V1, V2, V3);
}
//=======================================================================
@@ -613,17 +533,9 @@ gp_Vec2d Geom2d_BSplineCurve::LocalDN
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
gp_Vec2d V;
if ( rational ) {
BSplCLib::DN(u,N,index,deg,periodic,POLES,
&weights->Array1(),
FKNOTS,FMULTS,V);
}
else {
BSplCLib::DN(u,N,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,V);
}
BSplCLib::DN (u, N, index, deg, periodic, POLES,
rational ? &weights->Array1() : BSplCLib::NoWeights(),
FKNOTS, FMULTS, V);
return V;
}
@@ -820,7 +732,12 @@ void Geom2d_BSplineCurve::LocateU
else {
I1 = 1;
BSplCLib::Hunt (CKnots, NewU, I1);
while ( Abs( CKnots(I1+1) - NewU) <= PParametricTolerance) I1++;
I1 = Max (Min (I1, CKnots.Upper()), CKnots.Lower());
while (I1 + 1 <= CKnots.Upper()
&& Abs (CKnots (I1 + 1) - NewU) <= PParametricTolerance)
{
I1++;
}
if ( Abs( CKnots(I1) - NewU) <= PParametricTolerance) {
I2 = I1;
}
@@ -835,63 +752,45 @@ void Geom2d_BSplineCurve::LocateU
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::Resolution(const Standard_Real ToleranceUV,
Standard_Real & UTolerance)
void Geom2d_BSplineCurve::Resolution (const Standard_Real ToleranceUV,
Standard_Real& UTolerance)
{
Standard_Integer ii ;
if(!maxderivinvok){
if ( periodic) {
if (!maxderivinvok)
{
if (periodic)
{
Standard_Integer NbKnots, NbPoles;
BSplCLib::PrepareUnperiodize( deg,
mults->Array1(),
NbKnots,
NbPoles);
TColgp_Array1OfPnt2d new_poles(1,NbPoles) ;
TColStd_Array1OfReal new_weights(1,NbPoles) ;
for(ii = 1 ; ii <= NbPoles ; ii++) {
new_poles(ii) = poles->Array1()(((ii-1) % poles->Length()) + 1) ;
BSplCLib::PrepareUnperiodize (deg, mults->Array1(), NbKnots, NbPoles);
TColgp_Array1OfPnt2d new_poles (1, NbPoles);
TColStd_Array1OfReal new_weights (1, NbPoles);
for (Standard_Integer ii = 1; ii <= NbPoles ; ii++)
{
new_poles (ii) = poles->Array1()(((ii-1) % poles->Length()) + 1);
}
if (rational) {
for(ii = 1 ; ii <= NbPoles ; ii++) {
new_weights(ii) = weights->Array1()(((ii-1) % poles->Length()) + 1) ;
}
BSplCLib::Resolution(new_poles,
&new_weights,
new_poles.Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
else {
BSplCLib::Resolution(new_poles,
BSplCLib::NoWeights(),
new_poles.Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
if (rational)
{
for (Standard_Integer ii = 1; ii <= NbPoles; ii++)
{
new_weights (ii) = weights->Array1()(((ii-1) % poles->Length()) + 1);
}
}
BSplCLib::Resolution (new_poles,
rational ? &new_weights : BSplCLib::NoWeights(),
new_poles.Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv);
}
else {
if (rational) {
BSplCLib::Resolution(poles->Array1(),
&weights->Array1(),
poles->Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
else {
BSplCLib::Resolution(poles->Array1(),
BSplCLib::NoWeights(),
poles->Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
else
{
BSplCLib::Resolution (poles->Array1(),
rational ? &weights->Array1() : BSplCLib::NoWeights(),
poles->Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv);
}
maxderivinvok = 1;
}

View File

@@ -268,21 +268,10 @@ void GeomAdaptor_SurfaceOfRevolution::VIntervals(TColStd_Array1OfReal& T,
//purpose :
//=======================================================================
Handle(Adaptor3d_HSurface) GeomAdaptor_SurfaceOfRevolution::UTrim
(const Standard_Real
#ifndef No_Exception
First
#endif
,const Standard_Real
#ifndef No_Exception
Last
#endif
,const Standard_Real
) const
Handle(Adaptor3d_HSurface) GeomAdaptor_SurfaceOfRevolution::UTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const
{
#ifndef No_Exception
Standard_Real Eps = Precision::PConfusion();
#endif
const Standard_Real Eps = Precision::PConfusion();
(void )Eps; (void )First; (void )Last; (void )Tol;
Standard_OutOfRange_Raise_if
( Abs(First) > Eps || Abs(Last - 2.*M_PI) > Eps,
"GeomAdaptor_SurfaceOfRevolution : UTrim : Parameters out of range");

View File

@@ -191,13 +191,21 @@ static void derivatives(Standard_Integer theMaxOrder,
else
{
for (i = 0; i <= theMaxOrder + theNU+ 1; i++)
{
for (j = i; j <= theMaxOrder + theNV + 1; j++)
{
if (i + j > theMinOrder)
{
theDerSurf.SetValue(i, j, theBasisSurf->DN(theU, theV, i, j));
if (i != j)
if (i != j
&& j <= theDerSurf.UpperRow()
&& i <= theDerSurf.UpperCol())
{
theDerSurf.SetValue(j, i, theBasisSurf->DN(theU, theV, j, i));
}
}
}
}
for (i = 0; i <= theMaxOrder + theNU; i++)
for (j = 0; j <= theMaxOrder + theNV; j++)
theDerNUV.SetValue(i, j, CSLib::DNNUV(i, j, theDerSurf));
@@ -776,7 +784,7 @@ gp_Vec GeomEvaluator_OffsetSurface::CalculateDN(
CSLib::Normal(theD1U, theD1V, the_D1MagTol, NStatus, Normal);
const Standard_Integer MaxOrder = (NStatus == CSLib_Defined) ? 0 : 3;
Standard_Integer OrderU, OrderV;
TColgp_Array2OfVec DerNUV(0, MaxOrder + theNu, 0, MaxOrder + theNu);
TColgp_Array2OfVec DerNUV(0, MaxOrder + theNu, 0, MaxOrder + theNv);
TColgp_Array2OfVec DerSurf(0, MaxOrder + theNu + 1, 0, MaxOrder + theNv + 1);
Standard_Real Umin = 0, Umax = 0, Vmin = 0, Vmax = 0;

View File

@@ -286,6 +286,19 @@ public:
//! Set marker's image texture.
void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage) { myMarkerImage = theImage; }
//! Returns TRUE if marker should be drawn using marker sprite (either user-provided or generated).
bool IsMarkerSprite() const
{
if (myMarkerType == Aspect_TOM_POINT
|| myMarkerType == Aspect_TOM_EMPTY)
{
return false;
}
return myMarkerType != Aspect_TOM_USERDEFINED
|| !myMarkerImage.IsNull();
}
//! @name parameters specific to text rendering
public:

View File

@@ -80,6 +80,7 @@ Graphic3d_ShaderProgram::Graphic3d_ShaderProgram()
: myNbLightsMax (THE_MAX_LIGHTS_DEFAULT),
myNbClipPlanesMax (THE_MAX_CLIP_PLANES_DEFAULT),
myNbFragOutputs (THE_NB_FRAG_OUTPUTS),
myHasDefSampler (true),
myHasAlphaTest (false),
myHasWeightOitOutput (false)
{

View File

@@ -138,6 +138,12 @@ public:
//! Note that this flag is designed for usage with - custom shader program may discard fragment regardless this flag.
void SetAlphaTest (Standard_Boolean theAlphaTest) { myHasAlphaTest = theAlphaTest; }
//! Return TRUE if standard program header should define default texture sampler occSampler0; TRUE by default for compatibility.
Standard_Boolean HasDefaultSampler() const { return myHasDefSampler; }
//! Set if standard program header should define default texture sampler occSampler0.
void SetDefaultSampler (Standard_Boolean theHasDefSampler) { myHasDefSampler = theHasDefSampler; }
//! Return true if Fragment Shader color should output the weighted OIT coverage; FALSE by default.
Standard_Boolean HasWeightOitOutput() const { return myHasWeightOitOutput; }
@@ -195,6 +201,7 @@ private:
Standard_Integer myNbLightsMax; //!< length of array of light sources (THE_MAX_LIGHTS)
Standard_Integer myNbClipPlanesMax; //!< length of array of clipping planes (THE_MAX_CLIP_PLANES)
Standard_Integer myNbFragOutputs; //!< length of array of Fragment Shader outputs (THE_NB_FRAG_OUTPUTS)
Standard_Boolean myHasDefSampler; //!< flag indicating that program defines default texture sampler occSampler0
Standard_Boolean myHasAlphaTest; //!< flag indicating that Fragment Shader performs alpha test
Standard_Boolean myHasWeightOitOutput; //!< flag indicating that Fragment Shader includes weighted OIT coverage

View File

@@ -40,13 +40,23 @@ IGESGeom_BSplineCurve::IGESGeom_BSplineCurve () { }
const Standard_Real aUmin, const Standard_Real aUmax,
const gp_XYZ& aNorm)
{
if (!allPoles.IsNull()) {
if (allPoles->Length() != allWeights->Length())
throw Standard_DimensionMismatch("IGESGeom_BSplineCurve : Init");
if (allKnots->Lower() != -aDegree || allKnots->Upper() != anIndex+1 ||
allWeights->Upper() != anIndex ||
allWeights->Lower() != 0 || allPoles->Lower() != 0)
throw Standard_DimensionMismatch("IGESGeom_BSplineCurve : Init");
if (!allPoles.IsNull())
{
if (allKnots->Lower() != -aDegree
|| allKnots->Upper() != anIndex + 1
|| allPoles->Lower() != 0)
{
throw Standard_DimensionMismatch ("IGESGeom_BSplineCurve : Init");
}
if (!allWeights.IsNull())
{
if (allPoles->Length() != allWeights->Length()
|| allWeights->Upper() != anIndex
|| allWeights->Lower() != 0)
{
throw Standard_DimensionMismatch ("IGESGeom_BSplineCurve : Init");
}
}
}
theIndex = anIndex;

View File

@@ -179,8 +179,7 @@ TopoDS_Vertex IGESToBRep_BRepEntity::TransferVertex
if ( Sh.IsNull()) {
Message_Msg Msg1156("IGES_1156"); //"the Vertex number %d is a null object." FAIL!!!
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
Msg1156.Arg("vertex %d");
Msg1156.Arg(index);
Msg1156.Arg("vertex");
Msg1156.Arg(label);
SendWarning(start,Msg1156);
}
@@ -227,7 +226,7 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferEdge
Msg1306.Arg(inum);
SendWarning(start,Msg1306);
TopoDS_Edge Sh;
AddShapeResult(start,Sh);
AddShapeResult(start,Sh); // add null shape to avoid shift of indexing
}
else {
TopoDS_Shape Sh = TC.TransferTopoCurve(thecurve);
@@ -285,11 +284,11 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferEdge
}
else if (Sh.ShapeType() == TopAbs_WIRE) {
// pas traite
Message_Msg Msg1325("IGES_1325"); //"Edge : result of TransferTopoCurve is WIRE"
Message_Msg Msg1325("IGES_1325"); //"Item %d of EdgeList cannot be represented by single edge (non-continuous or composite curve)."
Msg1325.Arg(inum);
SendWarning(start,Msg1325);
//AddWarning(start,"Edge : result of TransferTopoCurve is WIRE");
}
AddShapeResult(start,Sh);
}
}
else {
Message_Msg Msg1156("IGES_1156");
@@ -297,7 +296,8 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferEdge
Msg1156.Arg("underlying curve");
Msg1156.Arg(label);
SendWarning(start,Msg1156);
}
AddShapeResult(start,Sh); // add null shape to avoid shift of indexing
}
}
}
}
@@ -306,8 +306,7 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferEdge
if ( Sh.IsNull()) {
Message_Msg Msg1156("IGES_1156");
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
Msg1156.Arg("edge %d");
Msg1156.Arg(index);
Msg1156.Arg("edge");
Msg1156.Arg(label);
SendWarning(start,Msg1156);
}
@@ -371,14 +370,17 @@ TopoDS_Shape IGESToBRep_BRepEntity::TransferLoop(const Handle(IGESSolid_Loop)& s
else if (( itype == 0) && (theedge ->IsKind(STANDARD_TYPE(IGESSolid_EdgeList)))) {
DeclareAndCast(IGESSolid_EdgeList,thelist,theedge);
TopoDS_Shape Sh = TransferEdge(thelist,indexlist);
curve3d->Add (Sh);
}
if (Sh.IsNull())
{
continue; // skip non-translated edge hoping for the best; warning is already generated by TransferEdge()
}
curve3d->Add(Sh);
}
else {
Message_Msg Msg1365("IGES_1365"); //"Improper type for the edge"
Handle(TCollection_HAsciiString) label = GetModel()->StringLabel(start);
Msg1365.Arg(iedge);
SendWarning(start,Msg1365);
//AddWarning (start, "Improper type for the edge");
continue;
}
if (!orientation) curve3d->Reverse();

View File

@@ -125,7 +125,7 @@ IGESToBRep_IGESBoundary::IGESToBRep_IGESBoundary(const IGESToBRep_CurveAndSurfac
void IGESToBRep_IGESBoundary::Check(const Standard_Boolean,const Standard_Boolean,const Standard_Boolean,const Standard_Boolean)
{
// Implemented in Advanced Data Exchange
// Implemented in IGESControl_IGESBoundary, subject to refactoring
}
//=======================================================================

View File

@@ -1943,7 +1943,12 @@ void Law_BSpline::LocateU
else {
I1 = 1;
BSplCLib::Hunt (CKnots, NewU, I1);
while ( Abs( CKnots(I1+1) - NewU) <= Abs(ParametricTolerance)) I1++;
I1 = Max (Min (I1, CKnots.Upper()), CKnots.Lower());
while (I1 + 1 <= CKnots.Upper()
&& Abs (CKnots (I1 + 1) - NewU) <= Abs(ParametricTolerance))
{
I1++;
}
if ( Abs( CKnots(I1) - NewU) <= Abs(ParametricTolerance)) {
I2 = I1;
}
@@ -1982,20 +1987,19 @@ void Law_BSpline::
&poles->Array1()(1) ;
new_poles_array = (Standard_Real *)
&new_poles(1) ;
BSplCLib::MovePointAndTangent(U,
dimension,
delta,
delta_derivative,
Tolerance,
deg,
rational,
StartingCondition,
EndingCondition,
poles_array[0],
weights->Array1(),
flatknots->Array1(),
new_poles_array[0],
ErrorStatus) ;
BSplCLib::MovePointAndTangent (U,
dimension,
delta,
delta_derivative,
Tolerance,
deg,
StartingCondition,
EndingCondition,
poles_array[0],
rational ? &weights->Array1() : BSplCLib::NoWeights(),
flatknots->Array1(),
new_poles_array[0],
ErrorStatus);
if (!ErrorStatus) {
poles->ChangeArray1() = new_poles;
}

View File

@@ -215,9 +215,9 @@ void MAT_Arc::SetFirstArc(const MAT_Side aSide ,
const Handle(MAT_Arc)& anArc)
{
if (aSide == MAT_Left)
firstArcLeft = anArc.operator->();
firstArcLeft = anArc.get();
else
firstArcRight = anArc.operator->();
firstArcRight = anArc.get();
}
//========================================================================
@@ -228,9 +228,9 @@ void MAT_Arc::SetSecondArc(const MAT_Side aSide ,
const Handle(MAT_Arc)& anArc)
{
if (aSide == MAT_Left)
secondArcLeft = anArc.operator->();
secondArcLeft = anArc.get();
else
secondArcRight = anArc.operator->();
secondArcRight = anArc.get();
}
//========================================================================
@@ -243,17 +243,17 @@ void MAT_Arc::SetNeighbour(const MAT_Side aSide,
{
if (aSide == MAT_Left) {
if (aNode == FirstNode())
firstArcLeft = anArc.operator->();
firstArcLeft = anArc.get();
else if (aNode == SecondNode())
secondArcLeft = anArc.operator->();
secondArcLeft = anArc.get();
else
throw Standard_DomainError("MAT_Arc::SetNeighbour");
}
else {
if (aNode == FirstNode())
firstArcRight = anArc.operator->();
firstArcRight = anArc.get();
else if (aNode == SecondNode())
secondArcRight = anArc.operator->();
secondArcRight = anArc.get();
else
throw Standard_DomainError("MAT_Arc::SetNeighbour");
}

View File

@@ -77,7 +77,7 @@ Standard_Integer MAT_BasicElt::GeomIndex() const
//========================================================================
void MAT_BasicElt::SetStartArc(const Handle(MAT_Arc)& anArc)
{
startLeftArc = anArc.operator->();
startLeftArc = anArc.get();
}
@@ -87,7 +87,7 @@ void MAT_BasicElt::SetStartArc(const Handle(MAT_Arc)& anArc)
//========================================================================
void MAT_BasicElt::SetEndArc(const Handle(MAT_Arc)& anArc)
{
endLeftArc = anArc.operator->();
endLeftArc = anArc.get();
}
//========================================================================

View File

@@ -33,7 +33,7 @@ MAT_Node::MAT_Node(const Standard_Integer GeomIndex,
: geomIndex(GeomIndex),
distance(Distance)
{
aLinkedArc = LinkedArc.operator->();
aLinkedArc = LinkedArc.get();
}
//=============================================================================
@@ -156,7 +156,7 @@ Standard_Boolean MAT_Node::Infinite() const
//=============================================================================
void MAT_Node::SetLinkedArc (const Handle(MAT_Arc)& LinkedArc)
{
aLinkedArc = LinkedArc.operator->();
aLinkedArc = LinkedArc.get();
}
//=============================================================================

View File

@@ -29,6 +29,7 @@ class HClassName : public _Array1Type_, public Standard_Transient {
public: \
DEFINE_STANDARD_ALLOC \
DEFINE_NCOLLECTION_ALLOC \
HClassName () : _Array1Type_ () {} \
HClassName (const Standard_Integer theLower, \
const Standard_Integer theUpper) : \
_Array1Type_ (theLower,theUpper) {} \

View File

@@ -402,14 +402,9 @@ public:
//! Raises an exception if Key1 was not bound.
const TheKey2Type& Find1(const TheKey1Type& theKey1) const
{
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DoubleMap::Find1");
DoubleMapNode * pNode1 =
(DoubleMapNode *) myData1[Hasher1::HashCode(theKey1,NbBuckets())];
while (pNode1)
if (const TheKey2Type* aKey2 = Seek1 (theKey1))
{
if (Hasher1::IsEqual (pNode1->Key1(), theKey1))
return pNode1->Key2();
pNode1 = (DoubleMapNode*) pNode1->Next();
return *aKey2;
}
throw Standard_NoSuchObject("NCollection_DoubleMap::Find1");
}
@@ -420,31 +415,38 @@ public:
//! @return TRUE if Key1 has been found
Standard_Boolean Find1 (const TheKey1Type& theKey1,
TheKey2Type& theKey2) const
{
if (const TheKey2Type* aKey2 = Seek1 (theKey1))
{
theKey2 = *aKey2;
return true;
}
return false;
}
//! Find the Key1 and return pointer to Key2 or NULL if Key1 is not bound.
//! @param [in] theKey1 Key1 to find
//! @return pointer to Key2 or NULL if Key1 is not found
const TheKey2Type* Seek1 (const TheKey1Type& theKey1) const
{
for (DoubleMapNode* aNode1 = !IsEmpty() ? (DoubleMapNode* )myData1[Hasher1::HashCode (theKey1, NbBuckets())] : NULL;
aNode1 != NULL; aNode1 = (DoubleMapNode* )aNode1->Next())
{
if (Hasher1::IsEqual (aNode1->Key1(), theKey1))
{
theKey2 = aNode1->Key2();
return Standard_True;
return &aNode1->Key2();
}
}
return Standard_False;
return NULL;
}
//! Find the Key2 and return Key1 value.
//! Raises an exception if Key2 was not bound.
const TheKey1Type& Find2(const TheKey2Type& theKey2) const
{
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DoubleMap::Find2");
DoubleMapNode * pNode2 =
(DoubleMapNode *) myData2[Hasher2::HashCode(theKey2,NbBuckets())];
while (pNode2)
if (const TheKey1Type* aVal1 = Seek2 (theKey2))
{
if (Hasher2::IsEqual (pNode2->Key2(), theKey2))
return pNode2->Key1();
pNode2 = (DoubleMapNode*) pNode2->Next2();
return *aVal1;
}
throw Standard_NoSuchObject("NCollection_DoubleMap::Find2");
}
@@ -455,17 +457,29 @@ public:
//! @return TRUE if Key2 has been found
Standard_Boolean Find2 (const TheKey2Type& theKey2,
TheKey1Type& theKey1) const
{
if (const TheKey1Type* aVal1 = Seek2 (theKey2))
{
theKey1 = *aVal1;
return Standard_True;
}
return Standard_False;
}
//! Find the Key2 and return pointer to Key1 or NULL if not bound.
//! @param [in] theKey2 Key2 to find
//! @return pointer to Key1 if Key2 has been found
const TheKey1Type* Seek2 (const TheKey2Type& theKey2) const
{
for (DoubleMapNode* aNode2 = !IsEmpty() ? (DoubleMapNode* )myData2[Hasher2::HashCode (theKey2, NbBuckets())] : NULL;
aNode2 != NULL; aNode2 = (DoubleMapNode* )aNode2->Next2())
{
if (Hasher2::IsEqual (aNode2->Key2(), theKey2))
{
theKey1 = aNode2->Key1();
return Standard_True;
return &aNode2->Key1();
}
}
return Standard_False;
return NULL;
}
//! Clear data. If doReleaseMemory is false then the table of

View File

@@ -59,32 +59,6 @@ public:
return myPtr;
}
//! Move assignment.
//! This array will borrow all the data from theOther.
NCollection_LocalArray& Move (NCollection_LocalArray& theOther)
{
if (&theOther == this)
{
return *this;
}
Deallocate();
mySize = theOther.mySize;
if (theOther.myPtr == theOther.myBuffer)
{
// deep copy
myPtr = myBuffer;
memcpy (myPtr, theOther.myPtr, sizeof(theItem) * theOther.mySize);
memset (theOther.myPtr, 0, sizeof(theItem) * theOther.mySize);
}
else
{
myPtr = theOther.myPtr;
theOther.myPtr = theOther.myBuffer;
}
return *this;
}
private:
NCollection_LocalArray (const NCollection_LocalArray& );

View File

@@ -16,8 +16,8 @@
#ifndef NCollection_Shared_HeaderFile
#define NCollection_Shared_HeaderFile
#include <Standard_Type.hxx>
#include <NCollection_DefineAlloc.hxx>
//! Template defining a class derived from the specified base class and
//! Standard_Transient, and supporting OCCT RTTI.
//!

View File

@@ -18,11 +18,13 @@
#ifdef HAVE_TBB
#include <OSD_Parallel.hxx>
#include <OSD_ThreadPool.hxx>
#include <Standard_ProgramError.hxx>
#include <tbb/parallel_for.h>
#include <tbb/parallel_for_each.h>
#include <tbb/blocked_range.h>
#include <tbb/task_scheduler_init.h>
//=======================================================================
//function : forEach
@@ -34,15 +36,19 @@ void OSD_Parallel::forEach (UniversalIterator& theBegin,
const FunctorInterface& theFunctor,
Standard_Integer theNbItems)
{
(void )theNbItems;
try
{
tbb::parallel_for_each(theBegin, theEnd, theFunctor);
const Handle(OSD_ThreadPool)& aThreadPool = OSD_ThreadPool::DefaultPool();
const Standard_Integer aNbThreads = theNbItems > 0 ?
Min (theNbItems, aThreadPool->NbDefaultThreadsToLaunch()) : -1;
tbb::task_scheduler_init aScheduler (aNbThreads);
tbb::parallel_for_each (theBegin, theEnd, theFunctor);
}
catch (tbb::captured_exception& anException)
{
throw Standard_ProgramError(anException.what());
throw Standard_ProgramError (anException.what());
}
}
#endif /* HAVE_TBB */
#endif /* HAVE_TBB */

View File

@@ -86,9 +86,13 @@ void OpenGl_Aspects::SetAspect (const Handle(Graphic3d_Aspects)& theAspect)
: Graphic3d_TOSM_UNLIT;
// invalidate resources
myResTextureSet.UpdateRediness (myAspect->TextureSet());
myResTextureSet.UpdateRediness (myAspect);
myResSprite.UpdateRediness (myAspect);
myResProgram.UpdateRediness (myAspect);
if (!myResSprite.IsReady())
{
myResTextureSet.Invalidate();
}
}
// =======================================================================

View File

@@ -45,9 +45,12 @@ public:
void SetNoLighting() { myShadingModel = Graphic3d_TOSM_UNLIT; }
//! Returns textures map.
const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx) const
const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx,
bool theToHighlight = false) const
{
return myResTextureSet.TextureSet (theCtx, myAspect->TextureSet());
const Handle(OpenGl_PointSprite)& aSprite = myResSprite.Sprite (theCtx, myAspect, false);
const Handle(OpenGl_PointSprite)& aSpriteA = myResSprite.Sprite (theCtx, myAspect, true);
return myResTextureSet.TextureSet (theCtx, myAspect, aSprite, aSpriteA, theToHighlight);
}
//! Init and return OpenGl shader program resource.
@@ -60,18 +63,24 @@ public:
//! @return marker size
Standard_ShortReal MarkerSize() const { return myResSprite.MarkerSize(); }
//! Init and return OpenGl point sprite resource.
//! @return point sprite texture.
const Handle(OpenGl_TextureSet)& SpriteRes (const Handle(OpenGl_Context)& theCtx) const
//! Return TRUE if OpenGl point sprite resource defines texture.
bool HasPointSprite (const Handle(OpenGl_Context)& theCtx) const
{
return myResSprite.Sprite (theCtx, myAspect);
return myResSprite.HasPointSprite (theCtx, myAspect);
}
//! Init and return OpenGl highlight point sprite resource.
//! @return point sprite texture for highlight.
const Handle(OpenGl_TextureSet)& SpriteHighlightRes (const Handle(OpenGl_Context)& theCtx) const
//! Return TRUE if OpenGl point sprite resource defined by obsolete Display List (bitmap).
bool IsDisplayListSprite (const Handle(OpenGl_Context)& theCtx) const
{
return myResSprite.SpriteA (theCtx, myAspect);
return myResSprite.IsDisplayListSprite (theCtx, myAspect);
}
//! Init and return OpenGl point sprite resource.
//! @return point sprite texture.
const Handle(OpenGl_PointSprite)& SpriteRes (const Handle(OpenGl_Context)& theCtx,
bool theIsAlphaSprite) const
{
return myResSprite.Sprite (theCtx, myAspect, theIsAlphaSprite);
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;

View File

@@ -1450,21 +1450,21 @@ void OpenGl_AspectsSprite::Release (OpenGl_Context* theCtx)
if (theCtx != NULL)
{
if (mySprite->First()->ResourceId().IsEmpty())
if (mySprite->ResourceId().IsEmpty())
{
theCtx->DelayedRelease (mySprite->ChangeFirst());
theCtx->DelayedRelease (mySpriteA->ChangeFirst());
theCtx->DelayedRelease (mySprite);
theCtx->DelayedRelease (mySpriteA);
}
else
{
{
const TCollection_AsciiString aSpriteKey = mySprite->First()->ResourceId();
const TCollection_AsciiString aSpriteKey = mySprite->ResourceId();
mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
theCtx->ReleaseResource (aSpriteKey, Standard_True);
}
if (!mySpriteA.IsNull())
{
const TCollection_AsciiString aSpriteKeyA = mySpriteA->First()->ResourceId();
const TCollection_AsciiString aSpriteKeyA = mySpriteA->ResourceId();
mySpriteA.Nullify();
theCtx->ReleaseResource (aSpriteKeyA, Standard_True);
}
@@ -1474,6 +1474,36 @@ void OpenGl_AspectsSprite::Release (OpenGl_Context* theCtx)
mySpriteA.Nullify();
}
// =======================================================================
// function : HasPointSprite
// purpose :
// =======================================================================
bool OpenGl_AspectsSprite::HasPointSprite (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspects)
{
const Handle(OpenGl_PointSprite)& aSprite = Sprite (theCtx, theAspects, false);
return !aSprite.IsNull()
&& !aSprite->IsDisplayList();
}
// =======================================================================
// function : IsDisplayListSprite
// purpose :
// =======================================================================
bool OpenGl_AspectsSprite::IsDisplayListSprite (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspects)
{
#if !defined(GL_ES_VERSION_2_0)
const Handle(OpenGl_PointSprite)& aSprite = Sprite (theCtx, theAspects, false);
return !aSprite.IsNull()
&& aSprite->IsDisplayList();
#else
(void )theCtx;
(void )theAspects;
return false;
#endif
}
// =======================================================================
// function : UpdateRediness
// purpose :
@@ -1483,8 +1513,8 @@ void OpenGl_AspectsSprite::UpdateRediness (const Handle(Graphic3d_Aspects)& theA
// update sprite resource bindings
TCollection_AsciiString aSpriteKeyNew, aSpriteAKeyNew;
spriteKeys (theAspect->MarkerImage(), theAspect->MarkerType(), theAspect->MarkerScale(), theAspect->ColorRGBA(), aSpriteKeyNew, aSpriteAKeyNew);
const TCollection_AsciiString& aSpriteKeyOld = !mySprite.IsNull() ? mySprite ->First()->ResourceId() : THE_EMPTY_KEY;
const TCollection_AsciiString& aSpriteAKeyOld = !mySpriteA.IsNull() ? mySpriteA->First()->ResourceId() : THE_EMPTY_KEY;
const TCollection_AsciiString& aSpriteKeyOld = !mySprite.IsNull() ? mySprite ->ResourceId() : THE_EMPTY_KEY;
const TCollection_AsciiString& aSpriteAKeyOld = !mySpriteA.IsNull() ? mySpriteA->ResourceId() : THE_EMPTY_KEY;
if (aSpriteKeyNew.IsEmpty() || aSpriteKeyOld != aSpriteKeyNew
|| aSpriteAKeyNew.IsEmpty() || aSpriteAKeyOld != aSpriteAKeyNew)
{
@@ -1493,6 +1523,24 @@ void OpenGl_AspectsSprite::UpdateRediness (const Handle(Graphic3d_Aspects)& theA
}
}
// =======================================================================
// function : Sprite
// purpose :
// =======================================================================
const Handle(OpenGl_PointSprite)& OpenGl_AspectsSprite::Sprite (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspects,
bool theIsAlphaSprite)
{
if (!myIsSpriteReady)
{
build (theCtx, theAspects->MarkerImage(), theAspects->MarkerType(), theAspects->MarkerScale(), theAspects->ColorRGBA(), myMarkerSize);
myIsSpriteReady = true;
}
return theIsAlphaSprite && !mySpriteA.IsNull() && mySpriteA->IsValid()
? mySpriteA
: mySprite;
}
// =======================================================================
// function : build
// purpose :
@@ -1508,8 +1556,8 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
TCollection_AsciiString aNewKey, aNewKeyA;
spriteKeys (theMarkerImage, theType, theScale, theColor, aNewKey, aNewKeyA);
const TCollection_AsciiString& aSpriteKeyOld = !mySprite.IsNull() ? mySprite ->First()->ResourceId() : THE_EMPTY_KEY;
const TCollection_AsciiString& aSpriteAKeyOld = !mySpriteA.IsNull() ? mySpriteA->First()->ResourceId() : THE_EMPTY_KEY;
const TCollection_AsciiString& aSpriteKeyOld = !mySprite.IsNull() ? mySprite ->ResourceId() : THE_EMPTY_KEY;
const TCollection_AsciiString& aSpriteAKeyOld = !mySpriteA.IsNull() ? mySpriteA->ResourceId() : THE_EMPTY_KEY;
// release old shared resources
const Standard_Boolean aNewResource = aNewKey.IsEmpty()
@@ -1518,14 +1566,14 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
{
if (!mySprite.IsNull())
{
if (mySprite->First()->ResourceId().IsEmpty())
if (mySprite->ResourceId().IsEmpty())
{
theCtx->DelayedRelease (mySprite->ChangeFirst());
theCtx->DelayedRelease (mySprite);
mySprite.Nullify();
}
else
{
const TCollection_AsciiString anOldKey = mySprite->First()->ResourceId();
const TCollection_AsciiString anOldKey = mySprite->ResourceId();
mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
theCtx->ReleaseResource (anOldKey, Standard_True);
}
@@ -1535,14 +1583,14 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
{
if (!mySpriteA.IsNull())
{
if (mySpriteA->First()->ResourceId().IsEmpty())
if (mySpriteA->ResourceId().IsEmpty())
{
theCtx->DelayedRelease (mySpriteA->ChangeFirst());
theCtx->DelayedRelease (mySpriteA);
mySpriteA.Nullify();
}
else
{
const TCollection_AsciiString anOldKey = mySpriteA->First()->ResourceId();
const TCollection_AsciiString anOldKey = mySpriteA->ResourceId();
mySpriteA.Nullify(); // we need nullify all handles before ReleaseResource() call
theCtx->ReleaseResource (anOldKey, Standard_True);
}
@@ -1551,7 +1599,7 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
if (!aNewResource)
{
const OpenGl_PointSprite* aSprite = dynamic_cast<OpenGl_PointSprite*> (mySprite->First().get());
const OpenGl_PointSprite* aSprite = dynamic_cast<OpenGl_PointSprite*> (mySprite.get());
if (!aSprite->IsDisplayList())
{
theMarkerSize = Standard_ShortReal (Max (aSprite->SizeX(), aSprite->SizeY()));
@@ -1566,13 +1614,8 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
return;
}
if (mySprite.IsNull())
{
mySprite = new OpenGl_TextureSet (1);
mySpriteA = new OpenGl_TextureSet (1);
}
Handle(OpenGl_PointSprite) aSprite, aSpriteA;
Handle(OpenGl_PointSprite)& aSprite = mySprite;
Handle(OpenGl_PointSprite)& aSpriteA = mySpriteA;
if (!aNewKey.IsEmpty()
&& theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKeyA, aSpriteA) // alpha sprite could be shared
&& theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKey, aSprite))
@@ -1582,8 +1625,6 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
{
theMarkerSize = Standard_ShortReal (Max (aSprite->SizeX(), aSprite->SizeY()));
}
mySprite ->ChangeFirst() = aSprite;
mySpriteA->ChangeFirst() = aSpriteA;
return;
}
@@ -1593,8 +1634,6 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
aSpriteA = new OpenGl_PointSprite (aNewKeyA);
}
aSprite = new OpenGl_PointSprite (aNewKey);
mySprite ->ChangeFirst() = aSprite;
mySpriteA->ChangeFirst() = aSpriteA;
if (!aNewKey.IsEmpty())
{
theCtx->ShareResource (aNewKey, aSprite);

View File

@@ -18,7 +18,7 @@
#include <Graphic3d_TextureMap.hxx>
class OpenGl_Context;
class OpenGl_TextureSet;
class OpenGl_PointSprite;
//! OpenGl resources for custom point sprites.
class OpenGl_AspectsSprite
@@ -31,30 +31,25 @@ public:
Standard_ShortReal MarkerSize() const { return myMarkerSize; }
//! Return RGB sprite.
const Handle(OpenGl_TextureSet)& Sprite (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspecta)
{
if (!myIsSpriteReady)
{
build (theCtx, theAspecta->MarkerImage(), theAspecta->MarkerType(), theAspecta->MarkerScale(), theAspecta->ColorRGBA(), myMarkerSize);
myIsSpriteReady = true;
}
return mySprite;
}
//! Return Alpha sprite.
const Handle(OpenGl_TextureSet)& SpriteA (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspecta)
{
if (!myIsSpriteReady)
{
build (theCtx, theAspecta->MarkerImage(), theAspecta->MarkerType(), theAspecta->MarkerScale(), theAspecta->ColorRGBA(), myMarkerSize);
myIsSpriteReady = true;
}
return mySpriteA;
}
//! Return TRUE if resource is up-to-date.
bool IsReady() const { return myIsSpriteReady; }
//! Invalidate resource state.
void Invalidate() { myIsSpriteReady = false; }
//! Return TRUE if OpenGl point sprite resource defines texture.
Standard_EXPORT bool HasPointSprite (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspects);
//! Return TRUE if OpenGl point sprite resource defined by obsolete Display List (bitmap).
Standard_EXPORT bool IsDisplayListSprite (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspects);
//! Return sprite.
Standard_EXPORT const Handle(OpenGl_PointSprite)& Sprite (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspects,
bool theIsAlphaSprite);
//! Update texture resource up-to-date state.
Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
@@ -81,8 +76,8 @@ private:
private:
Handle(OpenGl_TextureSet) mySprite;
Handle(OpenGl_TextureSet) mySpriteA;
Handle(OpenGl_PointSprite) mySprite;
Handle(OpenGl_PointSprite) mySpriteA;
Standard_ShortReal myMarkerSize;
Standard_Boolean myIsSpriteReady;

View File

@@ -15,7 +15,7 @@
#include <OpenGl_Context.hxx>
#include <OpenGl_Sampler.hxx>
#include <OpenGl_Texture.hxx>
#include <OpenGl_PointSprite.hxx>
#include <OpenGl_TextureSet.hxx>
#include <Graphic3d_TextureParams.hxx>
@@ -33,12 +33,18 @@ namespace
// =======================================================================
void OpenGl_AspectsTextureSet::Release (OpenGl_Context* theCtx)
{
if (myTextures.IsNull())
if (myTextures[0].IsNull())
{
return;
}
for (OpenGl_TextureSet::Iterator aTextureIter (myTextures); aTextureIter.More(); aTextureIter.Next())
if (!myTextures[1].IsNull())
{
// ReleaseResource() will have no effect until nullifying all copies
myTextures[1]->InitZero();
}
for (OpenGl_TextureSet::Iterator aTextureIter (myTextures[0]); aTextureIter.More(); aTextureIter.Next())
{
Handle(OpenGl_Texture)& aTextureRes = aTextureIter.ChangeValue();
if (aTextureRes.IsNull())
@@ -54,6 +60,8 @@ void OpenGl_AspectsTextureSet::Release (OpenGl_Context* theCtx)
}
else
{
// OpenGl_PointSprite will be actually released later by OpenGl_AspectsSprite,
// see order OpenGl_Aspects::Release()
const TCollection_AsciiString aName = aTextureRes->ResourceId();
aTextureRes.Nullify(); // we need nullify all handles before ReleaseResource() call
theCtx->ReleaseResource (aName, Standard_True);
@@ -68,23 +76,33 @@ void OpenGl_AspectsTextureSet::Release (OpenGl_Context* theCtx)
// function : UpdateRediness
// purpose :
// =======================================================================
void OpenGl_AspectsTextureSet::UpdateRediness (const Handle(Graphic3d_TextureSet)& theTextures)
void OpenGl_AspectsTextureSet::UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect)
{
const Standard_Integer aNbTexturesOld = !myTextures.IsNull() ? myTextures->Size() : 0;
const Standard_Integer aNbTexturesNew = !theTextures.IsNull() ? theTextures->Size() : 0;
const Handle(Graphic3d_TextureSet)& aNewTextureSet = theAspect->TextureSet();
const Standard_Integer aNbTexturesOld = !myTextures[0].IsNull() ? myTextures[0]->Size() : 0;
Standard_Integer aNbTexturesNew = !aNewTextureSet.IsNull() && theAspect->ToMapTexture()
? aNewTextureSet->Size()
: 0;
if (theAspect->IsMarkerSprite())
{
++aNbTexturesNew;
}
if (aNbTexturesOld != aNbTexturesNew)
{
myIsTextureReady = Standard_False;
return;
}
if (aNbTexturesOld == 0)
if (aNbTexturesOld == 0
|| !theAspect->ToMapTexture())
{
return;
}
Graphic3d_TextureSet::Iterator aTextureIter (theTextures);
OpenGl_TextureSet::Iterator aResIter (myTextures);
for (; aResIter.More(); aResIter.Next(), aTextureIter.Next())
Graphic3d_TextureSet::Iterator aTextureIter (aNewTextureSet);
OpenGl_TextureSet::Iterator aResIter (myTextures[0]);
for (; aTextureIter.More(); aResIter.Next(), aTextureIter.Next())
{
const Handle(OpenGl_Texture)& aResource = aResIter.Value();
const Handle(Graphic3d_TextureMap)& aTexture = aTextureIter.Value();
@@ -122,83 +140,150 @@ void OpenGl_AspectsTextureSet::UpdateRediness (const Handle(Graphic3d_TextureSet
// purpose :
// =======================================================================
void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureSet)& theTextures)
const Handle(Graphic3d_Aspects)& theAspect,
const Handle(OpenGl_PointSprite)& theSprite,
const Handle(OpenGl_PointSprite)& theSpriteA)
{
const Handle(Graphic3d_TextureSet)& aNewTextureSet = theAspect->TextureSet();
const bool hasSprite = theAspect->IsMarkerSprite();
const Standard_Integer aNbTexturesOld = !myTextures[0].IsNull() ? myTextures[0]->Size() : 0;
Standard_Integer aNbTexturesNew = !aNewTextureSet.IsNull() && theAspect->ToMapTexture()
? aNewTextureSet->Size()
: 0;
if (hasSprite)
{
++aNbTexturesNew;
}
// release old texture resources
const Standard_Integer aNbTexturesOld = !myTextures.IsNull() ? myTextures->Size() : 0;
const Standard_Integer aNbTexturesNew = !theTextures.IsNull() ? theTextures->Size() : 0;
if (aNbTexturesOld != aNbTexturesNew)
{
Release (theCtx.get());
if (aNbTexturesNew > 0)
{
myTextures = new OpenGl_TextureSet (theTextures->Size());
myTextures[0] = new OpenGl_TextureSet (aNbTexturesNew);
}
else
{
myTextures.Nullify();
myTextures[0].Nullify();
myTextures[1].Nullify();
}
}
if (myTextures.IsNull())
if (myTextures[0].IsNull())
{
return;
}
Graphic3d_TextureSet::Iterator aTextureIter (theTextures);
OpenGl_TextureSet::Iterator aResIter (myTextures);
for (; aResIter.More(); aResIter.Next(), aTextureIter.Next())
if (theSprite == theSpriteA)
{
Handle(OpenGl_Texture)& aResource = aResIter.ChangeValue();
const Handle(Graphic3d_TextureMap)& aTexture = aTextureIter.Value();
if (!aResource.IsNull())
myTextures[1].Nullify();
}
else
{
if (myTextures[1].IsNull()
|| myTextures[1]->Size() != myTextures[0]->Size())
{
if (!aTexture.IsNull()
&& aTexture->GetId() == aResource->ResourceId()
&& aTexture->Revision() != aResource->Revision())
{
if (Handle(Image_PixMap) anImage = aTexture->GetImage())
{
aResource->Sampler()->SetParameters (aTexture->GetParams());
aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
aResource->SetRevision (aTexture->Revision());
continue;
}
}
if (aResource->ResourceId().IsEmpty())
{
theCtx->DelayedRelease (aResource);
aResource.Nullify();
}
else
{
const TCollection_AsciiString aTextureKey = aResource->ResourceId();
aResource.Nullify(); // we need nullify all handles before ReleaseResource() call
theCtx->ReleaseResource (aTextureKey, Standard_True);
}
myTextures[1] = new OpenGl_TextureSet (aNbTexturesNew);
}
if (!aTexture.IsNull())
else
{
const TCollection_AsciiString& aTextureKeyNew = aTexture->GetId();
if (aTextureKeyNew.IsEmpty()
|| !theCtx->GetResource<Handle(OpenGl_Texture)> (aTextureKeyNew, aResource))
myTextures[1]->InitZero();
}
}
if (theAspect->ToMapTexture())
{
Graphic3d_TextureSet::Iterator aTextureIter (aNewTextureSet);
OpenGl_TextureSet::Iterator aResIter0 (myTextures[0]);
for (; aTextureIter.More(); aResIter0.Next(), aTextureIter.Next())
{
Handle(OpenGl_Texture)& aResource = aResIter0.ChangeValue();
const Handle(Graphic3d_TextureMap)& aTexture = aTextureIter.Value();
if (!aResource.IsNull())
{
aResource = new OpenGl_Texture (aTextureKeyNew, aTexture->GetParams());
if (Handle(Image_PixMap) anImage = aTexture->GetImage())
if (!aTexture.IsNull()
&& aTexture->GetId() == aResource->ResourceId()
&& aTexture->Revision() != aResource->Revision())
{
aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
aResource->SetRevision (aTexture->Revision());
if (Handle(Image_PixMap) anImage = aTexture->GetImage())
{
aResource->Sampler()->SetParameters (aTexture->GetParams());
aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
aResource->SetRevision (aTexture->Revision());
continue;
}
}
if (!aTextureKeyNew.IsEmpty())
if (aResource->ResourceId().IsEmpty())
{
theCtx->ShareResource (aTextureKeyNew, aResource);
theCtx->DelayedRelease (aResource);
aResource.Nullify();
}
else
{
const TCollection_AsciiString aTextureKey = aResource->ResourceId();
aResource.Nullify(); // we need nullify all handles before ReleaseResource() call
theCtx->ReleaseResource (aTextureKey, Standard_True);
}
}
else
if (!aTexture.IsNull())
{
aResource->Sampler()->SetParameters (aTexture->GetParams());
const TCollection_AsciiString& aTextureKeyNew = aTexture->GetId();
if (aTextureKeyNew.IsEmpty()
|| !theCtx->GetResource<Handle(OpenGl_Texture)> (aTextureKeyNew, aResource))
{
aResource = new OpenGl_Texture (aTextureKeyNew, aTexture->GetParams());
if (Handle(Image_PixMap) anImage = aTexture->GetImage())
{
aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
aResource->SetRevision (aTexture->Revision());
}
if (!aTextureKeyNew.IsEmpty())
{
theCtx->ShareResource (aTextureKeyNew, aResource);
}
}
else
{
if (aTexture->Revision() != aResource->Revision())
{
if (Handle(Image_PixMap) anImage = aTexture->GetImage())
{
aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
aResource->SetRevision (aTexture->Revision());
}
}
aResource->Sampler()->SetParameters (aTexture->GetParams());
}
}
}
}
if (hasSprite)
{
myTextures[0]->ChangeLast() = theSprite;
if (!theSprite.IsNull())
{
theSprite ->Sampler()->Parameters()->SetTextureUnit (theCtx->SpriteTextureUnit());
}
if (!theSpriteA.IsNull())
{
theSpriteA->Sampler()->Parameters()->SetTextureUnit (theCtx->SpriteTextureUnit());
}
}
if (myTextures[1].IsNull())
{
return;
}
for (OpenGl_TextureSet::Iterator aResIter0 (myTextures[0]), aResIter1 (myTextures[1]); aResIter0.More(); aResIter0.Next(), aResIter1.Next())
{
aResIter1.ChangeValue() = aResIter0.Value();
}
if (hasSprite)
{
myTextures[1]->ChangeLast() = theSpriteA;
}
}

View File

@@ -14,11 +14,13 @@
#ifndef _OpenGl_AspectsTextureSet_Header
#define _OpenGl_AspectsTextureSet_Header
#include <Graphic3d_Aspects.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Graphic3d_TextureSet.hxx>
class OpenGl_Context;
class OpenGl_TextureSet;
class OpenGl_PointSprite;
//! OpenGl resources for custom textures.
class OpenGl_AspectsTextureSet
@@ -29,20 +31,31 @@ public:
//! Empty constructor.
OpenGl_AspectsTextureSet() : myIsTextureReady (Standard_False) {}
//! Return TRUE if resource is up-to-date.
bool IsReady() const { return myIsTextureReady; }
//! Invalidate resource state.
void Invalidate() { myIsTextureReady = false; }
//! Return textures array.
const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureSet)& theTextures)
const Handle(Graphic3d_Aspects)& theAspect,
const Handle(OpenGl_PointSprite)& theSprite,
const Handle(OpenGl_PointSprite)& theSpriteA,
bool theToHighlight)
{
if (!myIsTextureReady)
{
build (theCtx, theTextures);
build (theCtx, theAspect, theSprite, theSpriteA);
myIsTextureReady = true;
}
return myTextures;
return theToHighlight && !myTextures[1].IsNull()
? myTextures[1]
: myTextures[0];
}
//! Update texture resource up-to-date state.
Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_TextureSet)& theTextures);
Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
//! Release texture resource.
Standard_EXPORT void Release (OpenGl_Context* theCtx);
@@ -51,11 +64,13 @@ private:
//! Build texture resource.
Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureSet)& theTextures);
const Handle(Graphic3d_Aspects)& theAspect,
const Handle(OpenGl_PointSprite)& theSprite,
const Handle(OpenGl_PointSprite)& theSpriteA);
private:
Handle(OpenGl_TextureSet) myTextures;
Handle(OpenGl_TextureSet) myTextures[2];
Standard_Boolean myIsTextureReady;
};

View File

@@ -170,6 +170,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
myIsInitialized (Standard_False),
myIsStereoBuffers (Standard_False),
myIsGlNormalizeEnabled (Standard_False),
mySpriteTexUnit (Graphic3d_TextureUnit_0),
myHasRayTracing (Standard_False),
myHasRayTracingTextures (Standard_False),
myHasRayTracingAdaptiveSampling (Standard_False),
@@ -1481,10 +1482,21 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
}
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &myMaxTexDim);
if (IsGlGreaterEqual (1, 5))
if (IsGlGreaterEqual (2, 0))
{
glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &myMaxTexCombined);
}
#if !defined(GL_ES_VERSION_2_0)
else if (IsGlGreaterEqual (1, 3))
{
// this is a maximum of texture units for FFP functionality,
// dramatically smaller than combined texture units available for GLSL
glGetIntegerv (GL_MAX_TEXTURE_UNITS, &myMaxTexCombined);
}
#endif
mySpriteTexUnit = myMaxTexCombined >= 2
? Graphic3d_TextureUnit_1
: Graphic3d_TextureUnit_0;
GLint aMaxVPortSize[2] = {0, 0};
glGetIntegerv (GL_MAX_VIEWPORT_DIMS, aMaxVPortSize);

View File

@@ -473,6 +473,9 @@ public:
//! @return value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
Standard_Integer MaxCombinedTextureUnits() const { return myMaxTexCombined; }
//! @return texture unit to be used for sprites
Graphic3d_TextureUnit SpriteTextureUnit() const { return mySpriteTexUnit; }
//! @return value for GL_MAX_SAMPLES
Standard_Integer MaxMsaaSamples() const { return myMaxMsaaSamples; }
@@ -946,6 +949,7 @@ private: // context info
Standard_Boolean myIsStereoBuffers; //!< context supports stereo buffering
Standard_Boolean myIsGlNormalizeEnabled; //!< GL_NORMALIZE flag
//!< Used to tell OpenGl that normals should be normalized
Graphic3d_TextureUnit mySpriteTexUnit; //!< texture unit for point sprite texture
Standard_Boolean myHasRayTracing; //! indicates whether ray tracing mode is supported
Standard_Boolean myHasRayTracingTextures; //! indicates whether textures in ray tracing mode are supported

View File

@@ -378,11 +378,11 @@ void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
while (myFirst != NULL)
{
OpenGl_ElementNode* aNext = myFirst->next;
OpenGl_Element::Destroy (theGlCtx.operator->(), myFirst->elem);
OpenGl_Element::Destroy (theGlCtx.get(), myFirst->elem);
delete myFirst;
myFirst = aNext;
}
myLast = NULL;
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspects);
OpenGl_Element::Destroy (theGlCtx.get(), myAspects);
}

View File

@@ -24,7 +24,7 @@ DEFINE_STANDARD_HANDLE(OpenGl_PointSprite, OpenGl_Texture)
//! On ancient hardware sprites will be drawn using bitmaps.
class OpenGl_PointSprite : public OpenGl_Texture
{
DEFINE_STANDARD_RTTIEXT(OpenGl_PointSprite, OpenGl_Texture)
public:
//! Create uninitialized resource.
@@ -36,6 +36,9 @@ public:
//! Destroy object - will release GPU memory if any.
Standard_EXPORT virtual void Release (OpenGl_Context* theCtx) Standard_OVERRIDE;
//! Returns TRUE for point sprite texture.
virtual bool IsPointSprite() const Standard_OVERRIDE { return true; }
//! @return true if this is display list bitmap
inline Standard_Boolean IsDisplayList() const
{
@@ -54,10 +57,6 @@ protected:
GLuint myBitmapList; //!< if of display list to draw sprite using glBitmap (for backward compatibility)
public:
DEFINE_STANDARD_RTTIEXT(OpenGl_PointSprite,OpenGl_Texture) // Type definition
};
#endif // _OpenGl_PointSprite_H__

View File

@@ -592,16 +592,12 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp
void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const
{
const OpenGl_Aspects* anAspectMarker = theWorkspace->Aspects();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const GLenum aDrawMode = !aCtx->ActiveProgram().IsNull()
&& aCtx->ActiveProgram()->HasTessellationStage()
? GL_PATCHES
: myDrawMode;
const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectMarker->SpriteRes (aCtx);
const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
if (aSpriteNorm != NULL
&& !aSpriteNorm->IsDisplayList())
if (anAspectMarker->HasPointSprite (aCtx))
{
// Textured markers will be drawn with the point sprites
aCtx->SetPointSize (anAspectMarker->MarkerSize());
@@ -644,9 +640,14 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork
}
#if !defined(GL_ES_VERSION_2_0)
// Textured markers will be drawn with the glBitmap
else if (anAspectMarker->Aspect()->MarkerType() != Aspect_TOM_POINT
&& aSpriteNorm != NULL)
else if (anAspectMarker->Aspect()->MarkerType() != Aspect_TOM_POINT)
{
const Handle(OpenGl_PointSprite)& aSpriteNorm = anAspectMarker->SpriteRes (aCtx, false);
if (aSpriteNorm.IsNull())
{
return;
}
/**if (!isHilight && (myPArray->vcolours != NULL))
{
for (Standard_Integer anIter = 0; anIter < myAttribs->NbElements; anIter++)
@@ -771,7 +772,8 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
const OpenGl_Aspects* anAspectFace = theWorkspace->ApplyAspects();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
Handle(OpenGl_TextureSet) aTextureBack;
const bool toEnableEnvMap = !aCtx->ActiveTextures().IsNull()
&& aCtx->ActiveTextures() == theWorkspace->EnvironmentTexture();
bool toDrawArray = true;
int toDrawInteriorEdges = 0; // 0 - no edges, 1 - glsl edges, 2 - polygonMode
if (myIsFillType)
@@ -818,23 +820,14 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
return;
}
}
// Temporarily disable environment mapping
aTextureBack = aCtx->BindTextures (Handle(OpenGl_TextureSet)());
}
// create VBOs on first render call
if (!myIsVboInit)
{
// compatibility - keep data to draw markers using display lists
Standard_Boolean toKeepData = Standard_False;
if (myDrawMode == GL_POINTS)
{
const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectFace->SpriteRes (aCtx);
const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
toKeepData = aSpriteNorm != NULL
&& aSpriteNorm->IsDisplayList();
}
Standard_Boolean toKeepData = myDrawMode == GL_POINTS
&& anAspectFace->IsDisplayListSprite (aCtx);
#if defined (GL_ES_VERSION_2_0)
processIndices (aCtx);
#endif
@@ -862,28 +855,16 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
case GL_POINTS:
{
aShadingModel = aCtx->ShaderManager()->ChooseMarkerShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectFace->SpriteRes (aCtx);
const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
if (aSpriteNorm != NULL
&& !aSpriteNorm->IsDisplayList())
{
const Handle(OpenGl_TextureSet)& aSprite = toHilight && anAspectFace->SpriteHighlightRes (aCtx)->First()->IsValid()
? anAspectFace->SpriteHighlightRes (aCtx)
: aSpriteNormRes;
aCtx->BindTextures (aSprite);
aCtx->ShaderManager()->BindMarkerProgram (aSprite, aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectFace->ShaderProgramRes (aCtx));
}
else
{
aCtx->ShaderManager()->BindMarkerProgram (Handle(OpenGl_TextureSet)(), aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectFace->ShaderProgramRes (aCtx));
}
aCtx->ShaderManager()->BindMarkerProgram (aCtx->ActiveTextures(),
aShadingModel, Graphic3d_AlphaMode_Opaque,
hasVertColor, anAspectFace->ShaderProgramRes (aCtx));
break;
}
case GL_LINES:
case GL_LINE_STRIP:
{
aShadingModel = aCtx->ShaderManager()->ChooseLineShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
aCtx->ShaderManager()->BindLineProgram (NULL,
aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(),
anAspectFace->Aspect()->LineType(),
aShadingModel,
Graphic3d_AlphaMode_Opaque,
@@ -894,9 +875,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
default:
{
aShadingModel = aCtx->ShaderManager()->ChooseFaceShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
const Handle(OpenGl_TextureSet)& aTextures = aCtx->ActiveTextures();
const Standard_Boolean toEnableEnvMap = (!aTextures.IsNull() && (aTextures == theWorkspace->EnvironmentTexture()));
aCtx->ShaderManager()->BindFaceProgram (aTextures,
aCtx->ShaderManager()->BindFaceProgram (aCtx->ActiveTextures(),
aShadingModel,
aCtx->ShaderManager()->MaterialState().HasAlphaCutoff() ? Graphic3d_AlphaMode_Mask : Graphic3d_AlphaMode_Opaque,
toDrawInteriorEdges == 1 ? anAspectFace->Aspect()->InteriorStyle() : Aspect_IS_SOLID,
@@ -952,7 +931,6 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
}
drawArray (theWorkspace, aFaceColors, hasColorAttrib);
aCtx->BindTextures (aTextureBack);
return;
}
@@ -1126,7 +1104,7 @@ void OpenGl_PrimitiveArray::InitBuffers (const Handle(OpenGl_Context)& th
const Handle(Graphic3d_BoundBuffer)& theBounds)
{
// Release old graphic resources
Release (theContext.operator->());
Release (theContext.get());
myIndices = theIndices;
myAttribs = theAttribs;

View File

@@ -23,10 +23,11 @@
//! Standard GLSL program combination bits.
enum OpenGl_ProgramOptions
{
OpenGl_PO_Point = 0x0001, //!< point marker
OpenGl_PO_VertColor = 0x0002, //!< per-vertex color
OpenGl_PO_TextureRGB = 0x0004, //!< handle RGB texturing
OpenGl_PO_TextureA = 0x0008, //!< handle Alpha texturing (point sprites only)
OpenGl_PO_VertColor = 0x0001, //!< per-vertex color
OpenGl_PO_TextureRGB = 0x0002, //!< handle RGB texturing
OpenGl_PO_PointSimple = 0x0004, //!< point marker without sprite
OpenGl_PO_PointSprite = 0x0008, //!< point sprite with RGB image
OpenGl_PO_PointSpriteA = OpenGl_PO_PointSimple|OpenGl_PO_PointSprite, //!< point sprite with Alpha image
OpenGl_PO_TextureEnv = 0x0010, //!< handle environment map
OpenGl_PO_StippleLine = 0x0020, //!< stipple line
OpenGl_PO_ClipPlanes1 = 0x0040, //!< handle 1 clipping plane
@@ -38,7 +39,8 @@ enum OpenGl_ProgramOptions
OpenGl_PO_WriteOit = 0x0800, //!< write coverage buffer for Blended Order-Independent Transparency
//
OpenGl_PO_NB = 0x1000, //!< overall number of combinations
OpenGl_PO_HasTextures = OpenGl_PO_TextureRGB|OpenGl_PO_TextureA,
OpenGl_PO_IsPoint = OpenGl_PO_PointSimple|OpenGl_PO_PointSprite|OpenGl_PO_PointSpriteA,
OpenGl_PO_HasTextures = OpenGl_PO_TextureRGB,
OpenGl_PO_NeedsGeomShader = OpenGl_PO_MeshEdges,
};

View File

@@ -22,6 +22,7 @@
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx>
#include <OpenGl_VertexBufferCompat.hxx>
#include <OpenGl_PointSprite.hxx>
#include <OpenGl_Workspace.hxx>
#include <TCollection_ExtendedString.hxx>
@@ -1297,6 +1298,7 @@ void OpenGl_ShaderManager::PushState (const Handle(OpenGl_ShaderProgram)& thePro
Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont()
{
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
aUniforms .Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerBaseColor", Graphic3d_TOS_FRAGMENT));
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec2 TexCoord", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
TCollection_AsciiString aSrcVert = TCollection_AsciiString()
@@ -1327,6 +1329,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont()
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
defaultGlslVersion (aProgramSrc, "font", 0);
aProgramSrc->SetDefaultSampler (false);
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbClipPlanesMax (0);
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
@@ -1392,6 +1395,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFboBlit()
}
#endif
aProgramSrc->SetId ("occt_blit");
aProgramSrc->SetDefaultSampler (false);
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbClipPlanesMax (0);
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
@@ -1483,6 +1487,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramOitCompositing (const St
}
aProgramSrc->SetId (theMsaa ? "occt_weight-oit-msaa" : "occt_weight-oit");
aProgramSrc->SetDefaultSampler (false);
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbClipPlanesMax (0);
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
@@ -1505,14 +1510,14 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramOitCompositing (const St
// function : pointSpriteAlphaSrc
// purpose :
// =======================================================================
TCollection_AsciiString OpenGl_ShaderManager::pointSpriteAlphaSrc (const Standard_Integer theBits)
TCollection_AsciiString OpenGl_ShaderManager::pointSpriteAlphaSrc (Standard_Integer theBits)
{
TCollection_AsciiString aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord ").a; }";
TCollection_AsciiString aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerPointSprite, " THE_VEC2_glPointCoord ").a; }";
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11 == NULL
&& (theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureA)
&& (theBits & OpenGl_PO_PointSpriteA) == OpenGl_PO_PointSpriteA)
{
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord ").r; }";
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerPointSprite, " THE_VEC2_glPointCoord ").r; }";
}
#else
(void )theBits;
@@ -1699,18 +1704,29 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
TCollection_AsciiString aSrcFragMainGetColor = EOL" occSetFragColor (getFinalColor());";
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
if ((theBits & OpenGl_PO_Point) != 0)
if ((theBits & OpenGl_PO_IsPoint) != 0)
{
#if defined(GL_ES_VERSION_2_0)
aSrcVertExtraMain += EOL" gl_PointSize = occPointSize;";
#endif
if ((theBits & OpenGl_PO_HasTextures) != 0)
if ((theBits & OpenGl_PO_PointSprite) != 0)
{
if ((theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureRGB)
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerPointSprite", Graphic3d_TOS_FRAGMENT));
if ((theBits & OpenGl_PO_PointSpriteA) != OpenGl_PO_PointSpriteA)
{
aSrcFragGetColor =
EOL"vec4 getColor(void) { return occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord "); }";
EOL"vec4 getColor(void) { return occTexture2D(occSamplerPointSprite, " THE_VEC2_glPointCoord "); }";
}
else if ((theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureRGB
&& (theBits & OpenGl_PO_VertColor) == 0)
{
aUniforms .Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerBaseColor", Graphic3d_TOS_VERTEX));
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 VertColor", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
aSrcVertExtraMain +=
EOL" VertColor = occTexture2D (occSamplerBaseColor, occTexCoord.xy);";
aSrcFragGetColor =
EOL"vec4 getColor(void) { return VertColor; }";
}
aSrcGetAlpha = pointSpriteAlphaSrc (theBits);
@@ -1731,6 +1747,17 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
}
else
{
if ((theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureRGB
&& (theBits & OpenGl_PO_VertColor) == 0)
{
aUniforms .Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerBaseColor", Graphic3d_TOS_VERTEX));
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 VertColor", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
aSrcVertExtraMain +=
EOL" VertColor = occTexture2D (occSamplerBaseColor, occTexCoord.xy);";
aSrcFragGetColor =
EOL"vec4 getColor(void) { return VertColor; }";
}
aSrcFragMainGetColor =
EOL" vec4 aColor = getColor();"
EOL" if (aColor.a <= 0.1) discard;"
@@ -1741,6 +1768,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
{
if ((theBits & OpenGl_PO_TextureRGB) != 0 || (theBits & OpenGl_PO_TextureEnv) != 0)
{
aUniforms .Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerBaseColor", Graphic3d_TOS_FRAGMENT));
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 TexCoord", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
}
@@ -1863,6 +1891,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
+ EOL"}";
defaultGlslVersion (aProgramSrc, theIsOutline ? "outline" : "unlit", theBits);
aProgramSrc->SetDefaultSampler (false);
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
@@ -1883,11 +1912,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
// function : pointSpriteShadingSrc
// purpose :
// =======================================================================
TCollection_AsciiString OpenGl_ShaderManager::pointSpriteShadingSrc (const TCollection_AsciiString theBaseColorSrc,
const Standard_Integer theBits)
TCollection_AsciiString OpenGl_ShaderManager::pointSpriteShadingSrc (const TCollection_AsciiString& theBaseColorSrc,
Standard_Integer theBits)
{
TCollection_AsciiString aSrcFragGetColor;
if ((theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureA)
if ((theBits & OpenGl_PO_PointSpriteA) == OpenGl_PO_PointSpriteA)
{
aSrcFragGetColor = pointSpriteAlphaSrc (theBits) +
EOL"vec4 getColor(void)"
@@ -1898,13 +1927,13 @@ TCollection_AsciiString OpenGl_ShaderManager::pointSpriteShadingSrc (const TColl
EOL" return aColor;"
EOL"}";
}
else if ((theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureRGB)
else if ((theBits & OpenGl_PO_PointSprite) == OpenGl_PO_PointSprite)
{
aSrcFragGetColor = TCollection_AsciiString() +
EOL"vec4 getColor(void)"
EOL"{"
EOL" vec4 aColor = " + theBaseColorSrc + ";"
EOL" aColor = occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord ") * aColor;"
EOL" aColor = occTexture2D(occSamplerPointSprite, " THE_VEC2_glPointCoord ") * aColor;"
EOL" if (aColor.a <= 0.1) discard;"
EOL" return aColor;"
EOL"}";
@@ -2062,29 +2091,38 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return gl_FrontFacing ? FrontColor : BackColor; }";
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
if ((theBits & OpenGl_PO_Point) != 0)
if ((theBits & OpenGl_PO_IsPoint) != 0)
{
#if defined(GL_ES_VERSION_2_0)
aSrcVertExtraMain += EOL" gl_PointSize = occPointSize;";
#endif
if ((theBits & OpenGl_PO_HasTextures) != 0)
if ((theBits & OpenGl_PO_PointSprite) != 0)
{
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11 != NULL
&& myContext->IsGlGreaterEqual (2, 1))
{
aProgramSrc->SetHeader ("#version 120"); // gl_PointCoord has been added since GLSL 1.2
}
#endif
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11 != NULL
&& myContext->IsGlGreaterEqual (2, 1))
{
aProgramSrc->SetHeader ("#version 120"); // gl_PointCoord has been added since GLSL 1.2
}
#endif
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerPointSprite", Graphic3d_TOS_FRAGMENT));
aSrcFragGetColor = pointSpriteShadingSrc ("gl_FrontFacing ? FrontColor : BackColor", theBits);
}
if ((theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureRGB
&& (theBits & OpenGl_PO_VertColor) == 0)
{
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerBaseColor", Graphic3d_TOS_VERTEX));
aSrcVertColor = EOL"vec4 getVertColor(void) { return occTexture2D (occSamplerBaseColor, occTexCoord.xy); }";
}
}
else
{
if ((theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureRGB)
{
aUniforms .Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerBaseColor", Graphic3d_TOS_FRAGMENT));
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 TexCoord", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
aSrcVertExtraMain += THE_VARY_TexCoord_Trsf;
@@ -2141,7 +2179,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 BackColor", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
Standard_Integer aNbLights = 0;
const TCollection_AsciiString aLights = stdComputeLighting (aNbLights, (theBits & OpenGl_PO_VertColor) != 0);
const TCollection_AsciiString aLights = stdComputeLighting (aNbLights, !aSrcVertColor.IsEmpty());
aSrcVert = TCollection_AsciiString()
+ THE_FUNC_transformNormal
+ EOL
@@ -2174,6 +2212,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
const TCollection_AsciiString aProgId = TCollection_AsciiString ("gouraud-") + genLightKey (myLightSourceState.LightSources()) + "-";
defaultGlslVersion (aProgramSrc, aProgId, theBits);
aProgramSrc->SetDefaultSampler (false);
aProgramSrc->SetNbLightsMax (aNbLights);
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
@@ -2223,29 +2262,41 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
TCollection_AsciiString aSrcFrag, aSrcFragExtraOut, aSrcFragGetVertColor, aSrcFragExtraMain;
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return " thePhongCompLight "; }";
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
if ((theBits & OpenGl_PO_Point) != 0)
if ((theBits & OpenGl_PO_IsPoint) != 0)
{
#if defined(GL_ES_VERSION_2_0)
aSrcVertExtraMain += EOL" gl_PointSize = occPointSize;";
#endif
if ((theBits & OpenGl_PO_HasTextures) != 0)
if ((theBits & OpenGl_PO_PointSprite) != 0)
{
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11 != NULL
&& myContext->IsGlGreaterEqual (2, 1))
{
aProgramSrc->SetHeader ("#version 120"); // gl_PointCoord has been added since GLSL 1.2
}
#endif
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11 != NULL
&& myContext->IsGlGreaterEqual (2, 1))
{
aProgramSrc->SetHeader ("#version 120"); // gl_PointCoord has been added since GLSL 1.2
}
#endif
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerPointSprite", Graphic3d_TOS_FRAGMENT));
aSrcFragGetColor = pointSpriteShadingSrc (thePhongCompLight, theBits);
}
if ((theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureRGB
&& (theBits & OpenGl_PO_VertColor) == 0)
{
aUniforms .Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerBaseColor", Graphic3d_TOS_VERTEX));
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 VertColor", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
aSrcVertExtraMain += EOL" VertColor = occTexture2D (occSamplerBaseColor, occTexCoord.xy);";
aSrcFragGetVertColor = EOL"vec4 getVertColor(void) { return VertColor; }";
}
}
else
{
if ((theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureRGB)
{
aUniforms .Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D occSamplerBaseColor", Graphic3d_TOS_FRAGMENT));
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 TexCoord", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
aSrcVertExtraMain += THE_VARY_TexCoord_Trsf;
@@ -2329,7 +2380,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
: EOL"#define getFinalColor getColor";
Standard_Integer aNbLights = 0;
const TCollection_AsciiString aLights = stdComputeLighting (aNbLights, (theBits & OpenGl_PO_VertColor) != 0);
const TCollection_AsciiString aLights = stdComputeLighting (aNbLights, !aSrcFragGetVertColor.IsEmpty());
aSrcFrag = TCollection_AsciiString()
+ EOL
+ aSrcFragExtraOut
@@ -2345,6 +2396,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
const TCollection_AsciiString aProgId = TCollection_AsciiString (theIsFlatNormal ? "flat-" : "phong-") + genLightKey (myLightSourceState.LightSources()) + "-";
defaultGlslVersion (aProgramSrc, aProgId, theBits, isFlatNormal);
aProgramSrc->SetDefaultSampler (false);
aProgramSrc->SetNbLightsMax (aNbLights);
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
@@ -2536,6 +2588,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo (Handle(OpenGl_Sh
}
defaultGlslVersion (aProgramSrc, aName, 0);
aProgramSrc->SetDefaultSampler (false);
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbClipPlanesMax (0);
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
@@ -2581,6 +2634,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramBoundBox()
EOL"}";
defaultGlslVersion (aProgramSrc, "bndbox", 0);
aProgramSrc->SetDefaultSampler (false);
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbClipPlanesMax (0);
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
@@ -2647,3 +2701,33 @@ Standard_Boolean OpenGl_ShaderManager::bindProgramWithState (const Handle(OpenGl
PushState (theProgram);
return isBound;
}
// =======================================================================
// function : BindMarkerProgram
// purpose :
// =======================================================================
Standard_Boolean OpenGl_ShaderManager::BindMarkerProgram (const Handle(OpenGl_TextureSet)& theTextures,
Graphic3d_TypeOfShadingModel theShadingModel,
Graphic3d_AlphaMode theAlphaMode,
Standard_Boolean theHasVertColor,
const Handle(OpenGl_ShaderProgram)& theCustomProgram)
{
if (!theCustomProgram.IsNull()
|| myContext->caps->ffpEnable)
{
return bindProgramWithState (theCustomProgram);
}
Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, false, false);
if (!theTextures.IsNull()
&& theTextures->HasPointSprite())
{
aBits |= theTextures->Last()->IsAlpha() ? OpenGl_PO_PointSpriteA : OpenGl_PO_PointSprite;
}
else
{
aBits |= OpenGl_PO_PointSimple;
}
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
return bindProgramWithState (aProgram);
}

View File

@@ -141,22 +141,11 @@ public:
}
//! Bind program for point rendering
Standard_Boolean BindMarkerProgram (const Handle(OpenGl_TextureSet)& theTextures,
const Graphic3d_TypeOfShadingModel theShadingModel,
const Graphic3d_AlphaMode theAlphaMode,
const Standard_Boolean theHasVertColor,
const Handle(OpenGl_ShaderProgram)& theCustomProgram)
{
if (!theCustomProgram.IsNull()
|| myContext->caps->ffpEnable)
{
return bindProgramWithState (theCustomProgram);
}
const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, false, false) | OpenGl_PO_Point;
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
return bindProgramWithState (aProgram);
}
Standard_EXPORT Standard_Boolean BindMarkerProgram (const Handle(OpenGl_TextureSet)& theTextures,
Graphic3d_TypeOfShadingModel theShadingModel,
Graphic3d_AlphaMode theAlphaMode,
Standard_Boolean theHasVertColor,
const Handle(OpenGl_ShaderProgram)& theCustomProgram);
//! Bind program for rendering alpha-textured font.
Standard_Boolean BindFontProgram (const Handle(OpenGl_ShaderProgram)& theCustomProgram)
@@ -510,10 +499,9 @@ protected:
aBits |= OpenGl_PO_TextureEnv;
}
else if (!theTextures.IsNull()
&& !theTextures->IsEmpty()
&& !theTextures->First().IsNull())
&& theTextures->HasNonPointSprite())
{
aBits |= theTextures->First()->IsAlpha() ? OpenGl_PO_TextureA : OpenGl_PO_TextureRGB;
aBits |= OpenGl_PO_TextureRGB;
}
if (theHasVertColor
&& theInteriorStyle != Aspect_IS_HIDDENLINE)
@@ -554,10 +542,11 @@ protected:
}
//! Prepare standard GLSL program for accessing point sprite alpha.
Standard_EXPORT TCollection_AsciiString pointSpriteAlphaSrc (const Standard_Integer theBits);
Standard_EXPORT TCollection_AsciiString pointSpriteAlphaSrc (Standard_Integer theBits);
//! Prepare standard GLSL program for computing point sprite shading.
Standard_EXPORT TCollection_AsciiString pointSpriteShadingSrc (const TCollection_AsciiString theBaseColorSrc, const Standard_Integer theBits);
Standard_EXPORT TCollection_AsciiString pointSpriteShadingSrc (const TCollection_AsciiString& theBaseColorSrc,
Standard_Integer theBits);
//! Prepare standard GLSL program for textured font.
Standard_EXPORT Standard_Boolean prepareStdProgramFont();

View File

@@ -49,6 +49,21 @@ static TCollection_AsciiString putLineNumbers (const TCollection_AsciiString& th
return aResultSource;
}
//! Return GLSL shader stage title.
static TCollection_AsciiString getShaderTypeString (GLenum theType)
{
switch (theType)
{
case GL_VERTEX_SHADER: return "Vertex Shader";
case GL_FRAGMENT_SHADER: return "Fragment Shader";
case GL_GEOMETRY_SHADER: return "Geometry Shader";
case GL_TESS_CONTROL_SHADER: return "Tessellation Control Shader";
case GL_TESS_EVALUATION_SHADER: return "Tessellation Evaluation Shader";
case GL_COMPUTE_SHADER: return "Compute Shader";
}
return "Shader";
}
// =======================================================================
// function : CreateFromSource
// purpose :
@@ -211,6 +226,7 @@ OpenGl_ShaderObject::~OpenGl_ShaderObject()
// purpose :
// =======================================================================
Standard_Boolean OpenGl_ShaderObject::LoadAndCompile (const Handle(OpenGl_Context)& theCtx,
const TCollection_AsciiString& theId,
const TCollection_AsciiString& theSource,
bool theIsVerbose,
bool theToPrintSource)
@@ -227,7 +243,8 @@ Standard_Boolean OpenGl_ShaderObject::LoadAndCompile (const Handle(OpenGl_Contex
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, theSource);
}
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, "Error! Failed to set shader source");
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ("Error! Failed to set ") + getShaderTypeString (myType) + " [" + theId + "] source");
return false;
}
@@ -244,7 +261,7 @@ Standard_Boolean OpenGl_ShaderObject::LoadAndCompile (const Handle(OpenGl_Contex
aLog = "Compilation log is empty.";
}
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ("Failed to compile shader object. Compilation log:\n") + aLog);
TCollection_AsciiString ("Failed to compile ") + getShaderTypeString (myType) + " [" + theId + "]. Compilation log:\n" + aLog);
return false;
}
else if (theCtx->caps->glslWarnings)
@@ -255,12 +272,24 @@ Standard_Boolean OpenGl_ShaderObject::LoadAndCompile (const Handle(OpenGl_Contex
&& !aLog.IsEqual ("No errors.\n"))
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
TCollection_AsciiString ("Shader compilation log:\n") + aLog);
getShaderTypeString (myType) + " [" + theId + "] compilation log:\n" + aLog);
}
}
return true;
}
// =======================================================================
// function : DumpSourceCode
// purpose :
// =======================================================================
void OpenGl_ShaderObject::DumpSourceCode (const Handle(OpenGl_Context)& theCtx,
const TCollection_AsciiString& theId,
const TCollection_AsciiString& theSource) const
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, 0, GL_DEBUG_SEVERITY_MEDIUM,
getShaderTypeString (myType) + " [" + theId + "] source code:\n" + theSource);
}
// =======================================================================
// function : LoadSource
// purpose : Loads shader source code
@@ -467,7 +496,7 @@ Standard_Boolean OpenGl_ShaderObject::updateDebugDump (const Handle(OpenGl_Conte
TCollection_AsciiString aNewSource;
if (restoreShaderSource (aNewSource, aFileName))
{
LoadAndCompile (theCtx, aNewSource);
LoadAndCompile (theCtx, theProgramId, aNewSource);
return Standard_True;
}
}

View File

@@ -88,14 +88,21 @@ public:
//! Wrapper for compiling shader object with verbose printing on error.
//! @param theCtx bound OpenGL context
//! @param theId GLSL program id to define file name
//! @param theSource source code to load
//! @param theIsVerbose flag to print log on error
//! @param theToPrintSource flag to print source code on error
Standard_EXPORT Standard_Boolean LoadAndCompile (const Handle(OpenGl_Context)& theCtx,
const TCollection_AsciiString& theId,
const TCollection_AsciiString& theSource,
bool theIsVerbose = true,
bool theToPrintSource = true);
//! Print source code of this shader object to messenger.
Standard_EXPORT void DumpSourceCode (const Handle(OpenGl_Context)& theCtx,
const TCollection_AsciiString& theId,
const TCollection_AsciiString& theSource) const;
//! Fetches information log of the last compile operation.
Standard_EXPORT Standard_Boolean FetchInfoLog (const Handle(OpenGl_Context)& theCtx,
TCollection_AsciiString& theLog);

View File

@@ -402,6 +402,11 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
aHeaderConstants += TCollection_AsciiString("#define THE_MAX_LIGHTS ") + myNbLightsMax + "\n";
aHeaderConstants += TCollection_AsciiString("#define THE_MAX_CLIP_PLANES ") + myNbClipPlanesMax + "\n";
aHeaderConstants += TCollection_AsciiString("#define THE_NB_FRAG_OUTPUTS ") + myNbFragOutputs + "\n";
if (!myProxy.IsNull()
&& myProxy->HasDefaultSampler())
{
aHeaderConstants += "#define THE_HAS_DEFAULT_SAMPLER\n";
}
const TCollection_AsciiString aSource = aHeaderVer // #version - header defining GLSL version, should be first
+ (!aHeaderVer.IsEmpty() ? "\n" : "")
@@ -412,7 +417,7 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
+ Shaders_Declarations_glsl // common declarations (global constants and Vertex Shader inputs)
+ Shaders_DeclarationsImpl_glsl
+ anIter.Value()->Source(); // the source code itself (defining main() function)
if (!aShader->LoadAndCompile (theCtx, aSource))
if (!aShader->LoadAndCompile (theCtx, myResourceId, aSource))
{
aShader->Release (theCtx.operator->());
return Standard_False;
@@ -420,16 +425,6 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
if (theCtx->caps->glslDumpLevel)
{
TCollection_AsciiString aShaderTypeMsg;
switch (anIter.Value()->Type())
{
case Graphic3d_TOS_COMPUTE: { aShaderTypeMsg = "Compute shader source code:\n"; break; }
case Graphic3d_TOS_VERTEX: { aShaderTypeMsg = "Vertex shader source code:\n"; break; }
case Graphic3d_TOS_TESS_CONTROL: { aShaderTypeMsg = "Tesselation control shader source code:\n"; break; }
case Graphic3d_TOS_TESS_EVALUATION: { aShaderTypeMsg = "Tesselation evaluation shader source code:\n"; break; }
case Graphic3d_TOS_GEOMETRY: { aShaderTypeMsg = "Geometry shader source code:\n"; break; }
case Graphic3d_TOS_FRAGMENT: { aShaderTypeMsg = "Fragment shader source code:\n"; break; }
}
TCollection_AsciiString anOutputSource = aSource;
if (theCtx->caps->glslDumpLevel == OpenGl_ShaderProgramDumpLevel_Short)
{
@@ -441,8 +436,7 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
+ aHeaderConstants
+ anIter.Value()->Source();
}
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, 0, GL_DEBUG_SEVERITY_MEDIUM,
TCollection_ExtendedString (aShaderTypeMsg + anOutputSource));
aShader->DumpSourceCode (theCtx, myResourceId, anOutputSource);
}
if (!AttachShader (theCtx, aShader))
@@ -484,6 +478,14 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
{
SetUniform (theCtx, aLocSampler, GLint(Graphic3d_TextureUnit_0));
}
if (const OpenGl_ShaderUniformLocation aLocSampler = GetUniformLocation (theCtx, "occSamplerBaseColor"))
{
SetUniform (theCtx, aLocSampler, GLint(Graphic3d_TextureUnit_BaseColor));
}
if (const OpenGl_ShaderUniformLocation aLocSampler = GetUniformLocation (theCtx, "occSamplerPointSprite"))
{
SetUniform (theCtx, aLocSampler, GLint(theCtx->SpriteTextureUnit()));
}
const TCollection_AsciiString aSamplerNamePrefix ("occSampler");
const Standard_Integer aNbUnitsMax = Max (theCtx->MaxCombinedTextureUnits(), Graphic3d_TextureUnit_NB);
@@ -616,7 +618,7 @@ Standard_Boolean OpenGl_ShaderProgram::Link (const Handle(OpenGl_Context)& theCt
aLog = "Linker log is empty.";
}
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ("Failed to link program object! Linker log:\n") + aLog);
TCollection_AsciiString ("Failed to link program object [") + myResourceId + "]! Linker log:\n" + aLog);
return false;
}
else if (theCtx->caps->glslWarnings)
@@ -627,7 +629,7 @@ Standard_Boolean OpenGl_ShaderProgram::Link (const Handle(OpenGl_Context)& theCt
&& !aLog.IsEqual ("No errors.\n"))
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
TCollection_AsciiString ("GLSL linker log:\n") + aLog);
TCollection_AsciiString ("GLSL linker log [") + myResourceId +"]:\n" + aLog);
}
}
return true;

View File

@@ -453,6 +453,9 @@ public:
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
//! Returns TRUE for point sprite texture.
virtual bool IsPointSprite() const { return false; }
protected:
//! Apply default sampler parameters after texture creation.

View File

@@ -28,3 +28,32 @@ bool OpenGl_TextureSet::IsModulate() const
|| myTextures.First().IsNull()
|| myTextures.First()->Sampler()->Parameters()->IsModulate();
}
// =======================================================================
// function : HasNonPointSprite
// purpose :
// =======================================================================
bool OpenGl_TextureSet::HasNonPointSprite() const
{
if (myTextures.IsEmpty())
{
return false;
}
else if (myTextures.Size() == 1)
{
return !myTextures.First().IsNull()
&& !myTextures.First()->IsPointSprite();
}
return !myTextures.First().IsNull();
}
// =======================================================================
// function : HasPointSprite
// purpose :
// =======================================================================
bool OpenGl_TextureSet::HasPointSprite() const
{
return !myTextures.IsEmpty()
&& !myTextures.Last().IsNull()
&& myTextures.Last()->IsPointSprite();
}

View File

@@ -75,6 +75,12 @@ public:
//! Return the first texture.
Handle(OpenGl_Texture)& ChangeFirst() { return myTextures.ChangeFirst(); }
//! Return the last texture.
const Handle(OpenGl_Texture)& Last() const { return myTextures.Last(); }
//! Return the last texture.
Handle(OpenGl_Texture)& ChangeLast() { return myTextures.ChangeLast(); }
//! Return the texture at specified position within [0, Size()) range.
const Handle(OpenGl_Texture)& Value (Standard_Integer theIndex) const { return myTextures.Value (theIndex); }
@@ -85,6 +91,18 @@ public:
//! or if texture is not set at all.
Standard_EXPORT bool IsModulate() const;
//! Return TRUE if other than point sprite textures are defined within point set.
Standard_EXPORT bool HasNonPointSprite() const;
//! Return TRUE if last texture is a point sprite.
Standard_EXPORT bool HasPointSprite() const;
//! Nullify all handles.
void InitZero()
{
myTextures.Init (Handle(OpenGl_Texture)());
}
protected:
NCollection_Array1<Handle(OpenGl_Texture)> myTextures;

View File

@@ -130,44 +130,47 @@ OpenGl_View::~OpenGl_View()
// =======================================================================
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
{
myGraduatedTrihedron.Release (theCtx.operator->());
myFrameStatsPrs.Release (theCtx.operator->());
myGraduatedTrihedron.Release (theCtx.get());
myFrameStatsPrs.Release (theCtx.get());
if (!myTextureEnv.IsNull())
{
for (OpenGl_TextureSet::Iterator aTextureIter (myTextureEnv); aTextureIter.More(); aTextureIter.Next())
if (!theCtx.IsNull())
{
theCtx->DelayedRelease (aTextureIter.ChangeValue());
aTextureIter.ChangeValue().Nullify();
for (OpenGl_TextureSet::Iterator aTextureIter (myTextureEnv); aTextureIter.More(); aTextureIter.Next())
{
theCtx->DelayedRelease (aTextureIter.ChangeValue());
aTextureIter.ChangeValue().Nullify();
}
}
myTextureEnv.Nullify();
}
if (myTextureParams != NULL)
{
myTextureParams->Release (theCtx.operator->());
myTextureParams->Release (theCtx.get());
}
if (myBgGradientArray != NULL)
{
myBgGradientArray->Release (theCtx.operator->());
myBgGradientArray->Release (theCtx.get());
}
if (myBgTextureArray != NULL)
{
myBgTextureArray->Release (theCtx.operator->());
myBgTextureArray->Release (theCtx.get());
}
myMainSceneFbos[0] ->Release (theCtx.operator->());
myMainSceneFbos[1] ->Release (theCtx.operator->());
myMainSceneFbosOit[0] ->Release (theCtx.operator->());
myMainSceneFbosOit[1] ->Release (theCtx.operator->());
myImmediateSceneFbos[0] ->Release (theCtx.operator->());
myImmediateSceneFbos[1] ->Release (theCtx.operator->());
myImmediateSceneFbosOit[0]->Release (theCtx.operator->());
myImmediateSceneFbosOit[1]->Release (theCtx.operator->());
myOpenGlFBO ->Release (theCtx.operator->());
myOpenGlFBO2 ->Release (theCtx.operator->());
myFullScreenQuad .Release (theCtx.operator->());
myFullScreenQuadFlip .Release (theCtx.operator->());
myMainSceneFbos[0] ->Release (theCtx.get());
myMainSceneFbos[1] ->Release (theCtx.get());
myMainSceneFbosOit[0] ->Release (theCtx.get());
myMainSceneFbosOit[1] ->Release (theCtx.get());
myImmediateSceneFbos[0] ->Release (theCtx.get());
myImmediateSceneFbos[1] ->Release (theCtx.get());
myImmediateSceneFbosOit[0]->Release (theCtx.get());
myImmediateSceneFbosOit[1]->Release (theCtx.get());
myOpenGlFBO ->Release (theCtx.get());
myOpenGlFBO2 ->Release (theCtx.get());
myFullScreenQuad .Release (theCtx.get());
myFullScreenQuadFlip .Release (theCtx.get());
releaseRaytraceResources (theCtx);
}

View File

@@ -1450,9 +1450,9 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Standard_Integer theS
myPostFSAAShaderSource.SetPrefix (aPrefixString);
myOutImageShaderSource.SetPrefix (aPrefixString);
if (!myRaytraceShader->LoadAndCompile (theGlContext, myRaytraceShaderSource.Source())
|| !myPostFSAAShader->LoadAndCompile (theGlContext, myPostFSAAShaderSource.Source())
|| !myOutImageShader->LoadAndCompile (theGlContext, myOutImageShaderSource.Source()))
if (!myRaytraceShader->LoadAndCompile (theGlContext, myRaytraceProgram->ResourceId(), myRaytraceShaderSource.Source())
|| !myPostFSAAShader->LoadAndCompile (theGlContext, myPostFSAAProgram->ResourceId(), myPostFSAAShaderSource.Source())
|| !myOutImageShader->LoadAndCompile (theGlContext, myOutImageProgram->ResourceId(), myOutImageShaderSource.Source()))
{
return safeFailBack ("Failed to compile ray-tracing fragment shaders", theGlContext);
}
@@ -1797,7 +1797,7 @@ inline void nullifyResource (const Handle(OpenGl_Context)& theGlContext, Handle(
{
if (!theResource.IsNull())
{
theResource->Release (theGlContext.operator->());
theResource->Release (theGlContext.get());
theResource.Nullify();
}
}
@@ -1818,10 +1818,10 @@ void OpenGl_View::releaseRaytraceResources (const Handle(OpenGl_Context)& theGlC
if (!theToRebuild) // complete release
{
myRaytraceFBO1[0]->Release (theGlContext.operator->());
myRaytraceFBO1[1]->Release (theGlContext.operator->());
myRaytraceFBO2[0]->Release (theGlContext.operator->());
myRaytraceFBO2[1]->Release (theGlContext.operator->());
myRaytraceFBO1[0]->Release (theGlContext.get());
myRaytraceFBO1[1]->Release (theGlContext.get());
myRaytraceFBO2[0]->Release (theGlContext.get());
myRaytraceFBO2[1]->Release (theGlContext.get());
nullifyResource (theGlContext, myRaytraceOutputTexture[0]);
nullifyResource (theGlContext, myRaytraceOutputTexture[1]);
@@ -1850,7 +1850,7 @@ void OpenGl_View::releaseRaytraceResources (const Handle(OpenGl_Context)& theGlC
if (myRaytraceScreenQuad.IsValid ())
{
myRaytraceScreenQuad.Release (theGlContext.operator->());
myRaytraceScreenQuad.Release (theGlContext.get());
}
}
}

View File

@@ -174,7 +174,7 @@ void OpenGl_View::Redraw()
// fetch OpenGl context state
aCtx->FetchState();
OpenGl_FrameBuffer* aFrameBuffer = myFBO.operator->();
OpenGl_FrameBuffer* aFrameBuffer = myFBO.get();
bool toSwap = aCtx->IsRender()
&& !aCtx->caps->buffersNoSwap
&& aFrameBuffer == NULL;
@@ -600,7 +600,7 @@ void OpenGl_View::RedrawImmediate()
const Graphic3d_StereoMode aStereoMode = myRenderParams.StereoMode;
Graphic3d_Camera::Projection aProjectType = myCamera->ProjectionType();
OpenGl_FrameBuffer* aFrameBuffer = myFBO.operator->();
OpenGl_FrameBuffer* aFrameBuffer = myFBO.get();
aCtx->FrameStats()->FrameStart (myWorkspace->View(), true);
if ( aFrameBuffer == NULL

View File

@@ -305,9 +305,11 @@ const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects()
myGlContext->SetShadingMaterial (myAspectsSet, myHighlightStyle);
}
if (myAspectsSet->Aspect()->ToMapTexture())
const Handle(OpenGl_TextureSet)& aTextureSet = myAspectsSet->TextureSet (myGlContext, ToHighlight());
if (!aTextureSet.IsNull()
|| myAspectsSet->Aspect()->ToMapTexture())
{
myGlContext->BindTextures (myAspectsSet->TextureSet (myGlContext));
myGlContext->BindTextures (aTextureSet);
}
else
{

View File

@@ -42,6 +42,7 @@
#include <TColgp_HArray1OfPnt2d.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
#include <Geom2dConvert.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
@@ -55,6 +56,8 @@
#include <GeomLib.hxx>
#include <Extrema_ExtPC.hxx>
#include <NCollection_DataMap.hxx>
#include <ElSLib.hxx>
#include <ElCLib.hxx>
//=======================================================================
//function : ComputeTolU
//purpose :
@@ -146,18 +149,19 @@ static Standard_Boolean IsoIsDeg (const Adaptor3d_Surface& S,
//=======================================================================
static void TrimC3d(Handle(Adaptor3d_HCurve)& myCurve,
Standard_Boolean* IsTrimmed,
const Standard_Real dt,
const gp_Pnt& Pole,
Standard_Boolean* IsTrimmed,
const Standard_Real dt,
const gp_Pnt& Pole,
Standard_Integer* SingularCase,
const Standard_Integer NumberOfSingularCase)
const Standard_Integer NumberOfSingularCase,
const Standard_Real TolConf)
{
Standard_Real f = myCurve->FirstParameter();
Standard_Real l = myCurve->LastParameter();
gp_Pnt P = myCurve->Value(f);
if(P.Distance(Pole) < Precision::Confusion()) {
if(P.Distance(Pole) <= TolConf) {
IsTrimmed[0] = Standard_True;
f = f+dt;
myCurve = myCurve->Trim(f, l, Precision::Confusion());
@@ -165,7 +169,7 @@ static void TrimC3d(Handle(Adaptor3d_HCurve)& myCurve,
}
P = myCurve->Value(l);
if(P.Distance(Pole) < Precision::Confusion()) {
if(P.Distance(Pole) <= TolConf) {
IsTrimmed[1] = Standard_True;
l = l-dt;
myCurve = myCurve->Trim(f, l, Precision::Confusion());
@@ -232,17 +236,24 @@ static void ExtendC2d (Handle(Geom2d_BSplineCurve)& aRes,
}
}
gp_Lin2d BoundLin(thePole, theBoundDir); //one of the bounds of rectangle
Standard_Real ParOnLin = 0.;
if (theBoundDir.IsParallel(aDBnd, 100.*Precision::Angular()))
{
ParOnLin = ElCLib::Parameter(aLin, thePole);
}
else
{
Standard_Real U1x = BoundLin.Direction().X();
Standard_Real U1y = BoundLin.Direction().Y();
Standard_Real U2x = aLin.Direction().X();
Standard_Real U2y = aLin.Direction().Y();
Standard_Real Uo21x = aLin.Location().X() - BoundLin.Location().X();
Standard_Real Uo21y = aLin.Location().Y() - BoundLin.Location().Y();
Standard_Real U1x = BoundLin.Direction().X();
Standard_Real U1y = BoundLin.Direction().Y();
Standard_Real U2x = aLin.Direction().X();
Standard_Real U2y = aLin.Direction().Y();
Standard_Real Uo21x = aLin.Location().X() - BoundLin.Location().X();
Standard_Real Uo21y = aLin.Location().Y() - BoundLin.Location().Y();
Standard_Real D = U1y*U2x-U1x*U2y;
Standard_Real ParOnLin = (Uo21y * U1x - Uo21x * U1y)/D; //parameter of intersection point
Standard_Real D = U1y*U2x - U1x*U2y;
ParOnLin = (Uo21y * U1x - Uo21x * U1y) / D; //parameter of intersection point
}
Handle(Geom2d_Line) aSegLine = new Geom2d_Line(aLin);
aSegment = (FirstOrLast == 0)?
@@ -392,6 +403,16 @@ void ProjLib_ProjectedCurve::Perform(const Handle(Adaptor3d_HCurve)& C)
GeomAbs_SurfaceType SType = mySurface->GetType();
GeomAbs_CurveType CType = myCurve->GetType();
Standard_Boolean isAnalyticalSurf = Standard_True;
Standard_Boolean IsTrimmed[2] = { Standard_False, Standard_False };
Standard_Integer SingularCase[2];
const Standard_Real eps = 0.01;
Standard_Real TolConf = Precision::Confusion();
Standard_Real dt = (LastPar - FirstPar) * eps;
Standard_Real U1 = 0.0, U2 = 0.0, V1 = 0.0, V2 = 0.0;
U1 = mySurface->FirstUParameter();
U2 = mySurface->LastUParameter();
V1 = mySurface->FirstVParameter();
V2 = mySurface->LastVParameter();
switch (SType)
{
@@ -429,6 +450,28 @@ void ProjLib_ProjectedCurve::Perform(const Handle(Adaptor3d_HCurve)& C)
// periodique en V !)
P.SetInBounds(myCurve->FirstParameter());
}
else
{
const Standard_Real Vmax = M_PI / 2.;
const Standard_Real Vmin = -Vmax;
const Standard_Real minang = 1.e-5 * M_PI;
gp_Sphere aSph = mySurface->Sphere();
Standard_Real anR = aSph.Radius();
Standard_Real f = myCurve->FirstParameter();
Standard_Real l = myCurve->LastParameter();
gp_Pnt Pf = myCurve->Value(f);
gp_Pnt Pl = myCurve->Value(l);
gp_Pnt aLoc = aSph.Position().Location();
Standard_Real maxdist = Max(Pf.Distance(aLoc), Pl.Distance(aLoc));
TolConf = Max(anR * minang, Abs(anR - maxdist));
//Surface has pole at V = Vmin and Vmax
gp_Pnt Pole = mySurface->Value(U1, Vmin);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 3, TolConf);
Pole = mySurface->Value(U1, Vmax);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 4, TolConf);
}
myResult = P;
}
break;
@@ -445,15 +488,11 @@ void ProjLib_ProjectedCurve::Perform(const Handle(Adaptor3d_HCurve)& C)
case GeomAbs_BSplineSurface:
{
isAnalyticalSurf = Standard_False;
Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False};
Standard_Integer SingularCase[2];
Standard_Real f, l, dt;
const Standard_Real eps = 0.01;
Standard_Real f, l;
f = myCurve->FirstParameter();
l = myCurve->LastParameter();
dt = (l - f) * eps;
Standard_Real U1 = 0.0, U2=0.0, V1=0.0, V2=0.0;
const Adaptor3d_Surface& S = mySurface->Surface();
U1 = S.FirstUParameter();
U2 = S.LastUParameter();
@@ -464,28 +503,28 @@ void ProjLib_ProjectedCurve::Perform(const Handle(Adaptor3d_HCurve)& C)
{
//Surface has pole at U = Umin
gp_Pnt Pole = mySurface->Value(U1, V1);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 1);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 1, TolConf);
}
if(IsoIsDeg(S, U2, GeomAbs_IsoU, 0., myTolerance))
{
//Surface has pole at U = Umax
gp_Pnt Pole = mySurface->Value(U2, V1);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 2);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 2, TolConf);
}
if(IsoIsDeg(S, V1, GeomAbs_IsoV, 0., myTolerance))
{
//Surface has pole at V = Vmin
gp_Pnt Pole = mySurface->Value(U1, V1);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 3);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 3, TolConf);
}
if(IsoIsDeg(S, V2, GeomAbs_IsoV, 0., myTolerance))
{
//Surface has pole at V = Vmax
gp_Pnt Pole = mySurface->Value(U1, V2);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 4);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 4, TolConf);
}
ProjLib_ComputeApproxOnPolarSurface polar;
@@ -531,10 +570,9 @@ void ProjLib_ProjectedCurve::Perform(const Handle(Adaptor3d_HCurve)& C)
default:
{
isAnalyticalSurf = Standard_False;
Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False};
Standard_Real Vsingular[2] = {0.0 , 0.0}; //for surfaces of revolution
Standard_Real f = 0.0, l = 0.0, dt = 0.0;
const Standard_Real eps = 0.01;
Standard_Real f = 0.0, l = 0.0;
dt = 0.0;
if(mySurface->GetType() == GeomAbs_SurfaceOfRevolution)
{
@@ -710,26 +748,59 @@ void ProjLib_ProjectedCurve::Perform(const Handle(Adaptor3d_HCurve)& C)
Comp.SetDegree(myDegMin, myDegMax);
Comp.SetMaxSegments(myMaxSegments);
Comp.SetBndPnt(myBndPnt);
Comp.Perform( myCurve, mySurface);
Comp.Perform(myCurve, mySurface);
if (Comp.Bezier().IsNull() && Comp.BSpline().IsNull())
return; // advanced projector has been failed too
myResult.Done();
// set the type
if ( SType == GeomAbs_Plane && CType == GeomAbs_BezierCurve)
Handle(Geom2d_BSplineCurve) aRes;
if (Comp.BSpline().IsNull())
{
myResult.SetType(GeomAbs_BezierCurve);
myResult.SetBezier(Comp.Bezier()) ;
aRes = Geom2dConvert::CurveToBSplineCurve(Comp.Bezier());
}
else
{
aRes = Comp.BSpline();
}
if ((IsTrimmed[0] || IsTrimmed[1]))
{
if (IsTrimmed[0])
{
//Add segment before start of curve
Standard_Real f = myCurve->FirstParameter();
ExtendC2d(aRes, f, -dt, U1, U2, V1, V2, 0, SingularCase[0]);
}
if (IsTrimmed[1])
{
//Add segment after end of curve
Standard_Real l = myCurve->LastParameter();
ExtendC2d(aRes, l, dt, U1, U2, V1, V2, 1, SingularCase[1]);
}
Handle(Geom2d_Curve) NewCurve2d;
GeomLib::SameRange(Precision::PConfusion(), aRes,
aRes->FirstParameter(), aRes->LastParameter(),
FirstPar, LastPar, NewCurve2d);
aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d);
myResult.SetBSpline(aRes);
myResult.SetType(GeomAbs_BSplineCurve);
myResult.SetBSpline(Comp.BSpline()) ;
}
else
{
// set the type
if (SType == GeomAbs_Plane && CType == GeomAbs_BezierCurve)
{
myResult.SetType(GeomAbs_BezierCurve);
myResult.SetBezier(Comp.Bezier());
}
else
{
myResult.SetType(GeomAbs_BSplineCurve);
myResult.SetBSpline(Comp.BSpline());
}
}
// set the periodicity flag
if (SType == GeomAbs_Plane &&
CType == GeomAbs_BSplineCurve &&
myCurve->IsPeriodic() )
CType == GeomAbs_BSplineCurve &&
myCurve->IsPeriodic())
{
myResult.SetPeriodic();
}

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