mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
632cbd6169 |
@@ -79,12 +79,6 @@ public:
|
||||
AnaglyphRight.SetRow (3, aZero);
|
||||
}
|
||||
|
||||
//! Returns resolution ratio.
|
||||
Standard_ShortReal ResolutionRatio() const
|
||||
{
|
||||
return Resolution / static_cast<Standard_ShortReal> (THE_DEFAULT_RESOLUTION);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Graphic3d_RenderingMode Method; //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
|
||||
|
@@ -140,8 +140,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
||||
myReadBuffer (0),
|
||||
myDrawBuffer (0),
|
||||
myDefaultVao (0),
|
||||
myIsGlDebugCtx (Standard_False),
|
||||
myResolutionRatio (1.0f)
|
||||
myIsGlDebugCtx (Standard_False)
|
||||
{
|
||||
// system-dependent fields
|
||||
#if defined(HAVE_EGL)
|
||||
@@ -2673,7 +2672,7 @@ void OpenGl_Context::SetPointSize (const Standard_ShortReal theSize)
|
||||
{
|
||||
if (!myActiveProgram.IsNull())
|
||||
{
|
||||
myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_POINT_SIZE), theSize * myResolutionRatio);
|
||||
myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_POINT_SIZE), theSize);
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
//myContext->core11fwd->glEnable (GL_VERTEX_PROGRAM_POINT_SIZE);
|
||||
#endif
|
||||
@@ -2681,7 +2680,7 @@ void OpenGl_Context::SetPointSize (const Standard_ShortReal theSize)
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
//else
|
||||
{
|
||||
core11fwd->glPointSize (theSize * myResolutionRatio);
|
||||
core11fwd->glPointSize (theSize);
|
||||
if (core20fwd != NULL)
|
||||
{
|
||||
//myContext->core11fwd->glDisable (GL_VERTEX_PROGRAM_POINT_SIZE);
|
||||
|
@@ -583,13 +583,6 @@ public: //! @name methods to alter or retrieve current state
|
||||
|
||||
Standard_EXPORT void DisableFeatures() const;
|
||||
|
||||
//! Set resolution ratio.
|
||||
//! Note that this method rounds @theRatio to nearest integer.
|
||||
void SetResolutionRatio (const Standard_ShortReal theRatio)
|
||||
{
|
||||
myResolutionRatio = Max (1.0f, std::floor (theRatio + 0.5f));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Wrapper to system function to retrieve GL function pointer by name.
|
||||
@@ -702,18 +695,16 @@ private: // context info
|
||||
|
||||
private: //! @name fields tracking current state
|
||||
|
||||
Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program
|
||||
Handle(OpenGl_Sampler) myTexSampler; //!< currently active sampler object
|
||||
Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object
|
||||
Standard_Integer myRenderMode; //!< value for active rendering mode
|
||||
Standard_Integer myReadBuffer; //!< current read buffer
|
||||
Standard_Integer myDrawBuffer; //!< current draw buffer
|
||||
unsigned int myDefaultVao; //!< default Vertex Array Object
|
||||
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
|
||||
TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
|
||||
TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB)
|
||||
Standard_ShortReal myResolutionRatio; //!< scaling factor for parameters like text size
|
||||
//!< to be properly displayed on device (screen / printer)
|
||||
Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program
|
||||
Handle(OpenGl_Sampler) myTexSampler; //!< currently active sampler object
|
||||
Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object
|
||||
Standard_Integer myRenderMode; //!< value for active rendering mode
|
||||
Standard_Integer myReadBuffer; //!< current read buffer
|
||||
Standard_Integer myDrawBuffer; //!< current draw buffer
|
||||
unsigned int myDefaultVao; //!< default Vertex Array Object
|
||||
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
|
||||
TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
|
||||
TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB)
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -281,9 +281,6 @@ void OpenGl_View::Redraw()
|
||||
// fetch OpenGl context state
|
||||
aCtx->FetchState();
|
||||
|
||||
// set resolution ratio
|
||||
aCtx->SetResolutionRatio (RenderingParams().ResolutionRatio());
|
||||
|
||||
OpenGl_FrameBuffer* aFrameBuffer = (OpenGl_FrameBuffer* )myFBO;
|
||||
bool toSwap = aCtx->IsRender()
|
||||
&& !aCtx->caps->buffersNoSwap
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <XCAFDoc_ShapeMapTool.hxx>
|
||||
#include <XCAFDoc_Location.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Expand
|
||||
@@ -213,4 +214,137 @@ Standard_Boolean XCAFDoc_Editor::setParams (const TDF_Label& Doc, const TDF_Labe
|
||||
TDataStd_Name::Set(Label, TCollection_ExtendedString(aName));
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compress
|
||||
//purpose : Convert assembly to compound
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_Editor::Compact (const TDF_Label& Doc, const TDF_Label& Shape)
|
||||
{
|
||||
if(Doc.IsNull() || Shape.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(Doc);
|
||||
|
||||
TopoDS_Shape aS = aShapeTool->GetShape(Shape);
|
||||
if (!aS.IsNull() && aS.ShapeType() == TopAbs_COMPOUND && aShapeTool->IsAssembly(Shape))
|
||||
{
|
||||
Shape.ForgetAttribute(XCAFDoc::AssemblyGUID());
|
||||
|
||||
TopoDS_Compound Comp;//new compound for Shape label
|
||||
BRep_Builder B;
|
||||
B.MakeCompound(Comp);
|
||||
|
||||
//convert assembly to compound
|
||||
TDF_ChildIterator anIter(Shape);
|
||||
for(; anIter.More(); anIter.Next())
|
||||
{
|
||||
TDF_Label aChild = anIter.Value();
|
||||
TopoDS_Shape aChildShape = aShapeTool->GetShape(aChild);
|
||||
|
||||
TDF_Label aPart;
|
||||
if(aShapeTool->GetReferredShape(aChild, aPart))
|
||||
{
|
||||
if (aChildShape.ShapeType() == TopAbs_COMPOUND && aShapeTool->IsAssembly(aPart))
|
||||
{
|
||||
//iterate next level if it needed
|
||||
Compact(Doc, aPart);
|
||||
}
|
||||
//get location
|
||||
Handle(XCAFDoc_Location) LocationAttribute;
|
||||
aChild.FindAttribute(XCAFDoc_Location::GetID(), LocationAttribute);
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
if(!LocationAttribute.IsNull())
|
||||
{
|
||||
aLoc = LocationAttribute->Get();
|
||||
}
|
||||
|
||||
if(aChildShape.ShapeType() != TopAbs_COMPOUND)
|
||||
{
|
||||
TDF_LabelSequence aLayers;
|
||||
TDF_LabelSequence aColors;
|
||||
Handle(TDataStd_Name) aName;
|
||||
getParams(Doc, aPart, aColors, aLayers, aName);
|
||||
|
||||
aChild.ForgetAllAttributes(Standard_False);
|
||||
//move shape
|
||||
aShapeTool->SetShape(aChild, aChildShape.Located(aLoc), Standard_False);
|
||||
|
||||
aChildShape.Free(Standard_True);
|
||||
B.Add(Comp, aChildShape.Located(aLoc));
|
||||
|
||||
setParams(Doc, aChild, aColors, aLayers, aName);
|
||||
}
|
||||
else
|
||||
{
|
||||
aChild.ForgetAllAttributes(Standard_False);
|
||||
}
|
||||
|
||||
//move subshapes
|
||||
TDF_LabelSequence aSub;
|
||||
aShapeTool->GetSubShapes(aPart,aSub);
|
||||
for(Standard_Integer i = 1; i <= aSub.Length(); i++)
|
||||
{
|
||||
TopoDS_Shape aShapeSub = aShapeTool->GetShape(aSub(i));
|
||||
|
||||
TDF_LabelSequence aLayers;
|
||||
TDF_LabelSequence aColors;
|
||||
Handle(TDataStd_Name) aName;
|
||||
getParams(Doc, aSub(i), aColors, aLayers, aName);
|
||||
|
||||
aSub(i).ForgetAllAttributes(Standard_False);
|
||||
|
||||
TDF_TagSource aTag;
|
||||
TDF_Label aSubC = aTag.NewChild(Shape);
|
||||
|
||||
TopLoc_Location loc = aLoc;
|
||||
if(aChildShape.ShapeType() == TopAbs_COMPOUND)
|
||||
{
|
||||
loc = aShapeSub.Location().Multiplied(aLoc);
|
||||
}
|
||||
|
||||
//set shape
|
||||
aShapeTool->SetShape(aSubC, aShapeSub.Located(loc), Standard_False);
|
||||
aSubC.ForgetAttribute(XCAFDoc_ShapeMapTool::GetID() );
|
||||
if(aChildShape.ShapeType() == TopAbs_COMPOUND)
|
||||
{
|
||||
aShapeSub.Free(Standard_True);
|
||||
B.Add(Comp, aShapeSub.Located(loc));
|
||||
}
|
||||
setParams(Doc, aSubC, aColors, aLayers, aName);
|
||||
}
|
||||
//remove part
|
||||
aPart.ForgetAllAttributes();
|
||||
}
|
||||
}
|
||||
aShapeTool->SetShape(Shape, Comp);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compress
|
||||
//purpose : Convert all assambly in Doc to compound
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_Editor::Compact (const TDF_Label& Doc)
|
||||
{
|
||||
Standard_Boolean result = Standard_False;
|
||||
TDF_LabelSequence aLabels;
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(Doc);
|
||||
aShapeTool->GetFreeShapes(aLabels);
|
||||
for(Standard_Integer i = 1; i <= aLabels.Length(); i++)
|
||||
{
|
||||
TopoDS_Shape aS = aShapeTool->GetShape(aLabels(i));
|
||||
if (!aS.IsNull() && aS.ShapeType() == TopAbs_COMPOUND && aShapeTool->IsAssembly(aLabels(i)))
|
||||
if (Compact(Doc, aLabels(i)))
|
||||
{
|
||||
result = Standard_True;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -41,6 +41,11 @@ public:
|
||||
//! Convert all compounds in Doc to assembly
|
||||
Standard_EXPORT static Standard_Boolean Expand (const TDF_Label& Doc, const Standard_Boolean recursively = Standard_True) ;
|
||||
|
||||
//! Convert Shape(assembly) to compound
|
||||
Standard_EXPORT static Standard_Boolean Compact (const TDF_Label& Doc, const TDF_Label& Shape) ;
|
||||
|
||||
//! Convert all assembly in Doc to compounds
|
||||
Standard_EXPORT static Standard_Boolean Compact (const TDF_Label& Doc) ;
|
||||
|
||||
|
||||
|
||||
|
@@ -399,9 +399,10 @@ TDF_Label XCAFDoc_ShapeTool::NewShape() const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ShapeTool::SetShape (const TDF_Label& L, const TopoDS_Shape& S)
|
||||
void XCAFDoc_ShapeTool::SetShape (const TDF_Label& L, const TopoDS_Shape& S,
|
||||
const Standard_Boolean theProtection)
|
||||
{
|
||||
if(IsReference(L) || !IsTopLevel(L) || /*IsAssembly(L) ||*/ !S.Location().IsIdentity())
|
||||
if(IsReference(L) || ((!IsTopLevel(L) ||!S.Location().IsIdentity()) && theProtection))
|
||||
return;
|
||||
|
||||
TDF_LabelSequence aSubShapes;
|
||||
@@ -1936,4 +1937,4 @@ void XCAFDoc_ShapeTool::makeSubShape (const TDF_Label& Part, const TopoDS_Shape&
|
||||
}
|
||||
makeSubShape(Part, aChildShape);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -203,12 +203,13 @@ public:
|
||||
Standard_EXPORT TDF_Label NewShape() const;
|
||||
|
||||
//! Sets representation (TopoDS_Shape) for top-level shape.
|
||||
//! If you set theProtection = Standard_False you can set shape for subshapes(not top-level)
|
||||
//! If S has location(location.IsIdentity() is false),
|
||||
//! command will be skipped. Sub-shapes of S which is
|
||||
//! subshape of old shape, will be stored ( all atributes will be stored).
|
||||
//! If a sub-label of L is not a sub-shape of the new shape,
|
||||
//! it will be removed.
|
||||
Standard_EXPORT void SetShape (const TDF_Label& L, const TopoDS_Shape& S);
|
||||
Standard_EXPORT void SetShape (const TDF_Label& L, const TopoDS_Shape& S, const Standard_Boolean theProtection = Standard_True);
|
||||
|
||||
//! Adds a new top-level (creates and returns a new label)
|
||||
//! If makeAssembly is True, treats TopAbs_COMPOUND shapes
|
||||
|
@@ -519,6 +519,51 @@ static Standard_Integer Expand (Draw_Interpretor& di, Standard_Integer argc, con
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static Standard_Integer Compact (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
di<<"Use: "<<argv[0]<<" Doc or Doc label1 label2 ... or Doc shape1 shape2 ..."<<"\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(TDocStd_Document) Doc;
|
||||
DDocStd::GetDocument(argv[1], Doc);
|
||||
if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
|
||||
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
if(!XCAFDoc_Editor::Compact(Doc->Main())){
|
||||
di << "The shape is not assembly" << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer i = 2; i < argc; i++)
|
||||
{
|
||||
TDF_Label aLabel;
|
||||
TDF_Tool::Label(Doc->GetData(), argv[i], aLabel);
|
||||
if(aLabel.IsNull()){
|
||||
TopoDS_Shape aShape;
|
||||
aShape = DBRep::Get(argv[i]);
|
||||
aLabel = aShapeTool->FindShape(aShape);
|
||||
}
|
||||
|
||||
if (!aLabel.IsNull()){
|
||||
if(!XCAFDoc_Editor::Compact(Doc->Main(), aLabel)){
|
||||
di << "The shape is not assembly" << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ di << argv[i] << " is not a shape" << "\n"; return 1; }
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void XDEDRAW_Common::InitCommands(Draw_Interpretor& di) {
|
||||
|
||||
static Standard_Boolean initactor = Standard_False;
|
||||
@@ -539,4 +584,6 @@ void XDEDRAW_Common::InitCommands(Draw_Interpretor& di) {
|
||||
di.Add("XExpand", "XExpand Doc recursively(0/1) or XExpand Doc recursively(0/1) label1 abel2 ..."
|
||||
"or XExpand Doc recursively(0/1) shape1 shape2 ...",__FILE__, Expand, g);
|
||||
|
||||
di.Add("XCompact", "XCompact Doc or XCompact Doc label1 abel2 ..."
|
||||
"or XCompact Doc shape1 shape2 ...",__FILE__, Compact, g);
|
||||
}
|
||||
|
@@ -1,25 +0,0 @@
|
||||
puts "============"
|
||||
puts "OCC26790 apply view resolution to built-in markers"
|
||||
puts "============"
|
||||
puts ""
|
||||
pload VISUALIZATION
|
||||
|
||||
vclear
|
||||
vclose all
|
||||
|
||||
vinit View1
|
||||
|
||||
for { set aMarkerType 0 } { $aMarkerType < 13 } { incr aMarkerType } {
|
||||
set aRow [expr $aMarkerType - 7]
|
||||
set aCol 5
|
||||
vmarkerstest m${aMarkerType} $aCol $aRow 0 MarkerType=$aMarkerType PointsOnSide=1
|
||||
}
|
||||
|
||||
vright
|
||||
vfit
|
||||
|
||||
vdump $imagedir/${casename}_1.png
|
||||
|
||||
vrenderparams -resolution 144
|
||||
|
||||
vdump $imagedir/${casename}_2.png
|
83
tests/bugs/xde/bug26302
Normal file
83
tests/bugs/xde/bug26302
Normal file
@@ -0,0 +1,83 @@
|
||||
puts "========"
|
||||
puts "OCC26302"
|
||||
puts "========"
|
||||
puts ""
|
||||
#######################################################################
|
||||
# Convert assembly to compound
|
||||
#######################################################################
|
||||
|
||||
pload ALL
|
||||
box b1 0 0 0 10 10 10
|
||||
box b2 10 0 0 10 10 10
|
||||
box b3 20 0 0 10 10 10
|
||||
explode b1
|
||||
explode b2
|
||||
explode b3
|
||||
explode b1_1
|
||||
explode b2_1
|
||||
explode b3_1
|
||||
compound b1 b2 c1
|
||||
compound c1 b3 c2
|
||||
NewDocument D
|
||||
XAddShape D c2 1
|
||||
XSetColor D b1 1 0 0
|
||||
XSetColor D b2 0 1 0
|
||||
XSetColor D b3 0 0 1
|
||||
XSetColor D b1_1_4 1 1 0
|
||||
XSetColor D b2_1_4 0 1 1
|
||||
XSetColor D b3_1_4 1 0 1
|
||||
XSetColor D b1_1_3 1 0 1
|
||||
XSetColor D b2_1_3 1 1 0
|
||||
XSetColor D b3_1_3 0 1 1
|
||||
XCompact D
|
||||
|
||||
if { [regexp "PART COMPOUND 0:1:1:1 \"ASSEMBLY\"" [Xdump D]] != 1 } {
|
||||
puts "ERROR: Structure of document is wrong.1"
|
||||
} else {
|
||||
if { [regexp "BLUE" [XGetShapeColor D 0:1:1:1:2]] != 1 } {
|
||||
puts "ERROR: Structure of document is wrong."
|
||||
} else {
|
||||
if { [regexp "RED" [XGetShapeColor D 0:1:1:1:3]] != 1 } {
|
||||
puts "ERROR: Structure of document is wrong."
|
||||
} else {
|
||||
if { [regexp "GREEN" [XGetShapeColor D 0:1:1:1:4]] != 1 } {
|
||||
puts "ERROR: Structure of document is wrong."
|
||||
} else {
|
||||
if { [regexp "YELLOW" [XGetShapeColor D 0:1:1:1:5]] != 1 } {
|
||||
puts "ERROR: Structure of document is wrong."
|
||||
} else {
|
||||
if { [regexp "MAGENTA" [XGetShapeColor D 0:1:1:1:6]] != 1 } {
|
||||
puts "ERROR: Structure of document is wrong."
|
||||
} else {
|
||||
if { [regexp "CYAN" [XGetShapeColor D 0:1:1:1:7]] != 1 } {
|
||||
puts "ERROR: Structure of document is wrong."
|
||||
} else {
|
||||
if { [regexp "YELLOW" [XGetShapeColor D 0:1:1:1:8]] != 1 } {
|
||||
puts "ERROR: Structure of document is wrong."
|
||||
} else {
|
||||
if { [regexp "MAGENTA" [XGetShapeColor D 0:1:1:1:9]] != 1 } {
|
||||
puts "ERROR: Structure of document is wrong."
|
||||
} else {
|
||||
if { [regexp "CYAN" [XGetShapeColor D 0:1:1:1:10]] != 1 } {
|
||||
puts "ERROR: Structure of document is wrong."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user