#include <TopExp_Explorer.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <StdSelect_ShapeTypeFilter.hxx>
-#include <AIS.hxx>
#include <AIS_ColoredShape.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_Trihedron.hxx>
#include <AIS_Axis.hxx>
-#include <AIS_Relation.hxx>
+#include <PrsDim.hxx>
+#include <PrsDim_Relation.hxx>
#include <AIS_TypeFilter.hxx>
#include <AIS_SignatureFilter.hxx>
#include <AIS_ListOfInteractive.hxx>
{
const Standard_Integer THE_COLOR_COMPONENT_NOT_PARSED = -1;
Graphic3d_Vec4i anIntegerColor (THE_COLOR_COMPONENT_NOT_PARSED);
- if (!parseNumericalColor (theNumberOfColorComponents, theColorComponentStrings, anIntegerColor))
+ if (!parseNumericalColor (theNumberOfColorComponents, theColorComponentStrings, anIntegerColor)
+ || anIntegerColor.maxComp() <= 1)
{
return false;
}
-
- const bool hasColorComponentGreaterThanOne = (anIntegerColor.maxComp() > 1);
if (anIntegerColor.a() == THE_COLOR_COMPONENT_NOT_PARSED)
{
anIntegerColor.a() = THE_MAX_INTEGER_COLOR_COMPONENT;
}
- Graphic3d_Vec4 aRealColor (anIntegerColor);
- if (hasColorComponentGreaterThanOne)
- {
- aRealColor /= static_cast<Standard_ShortReal> (THE_MAX_INTEGER_COLOR_COMPONENT);
- }
- theColor = Quantity_ColorRGBA (aRealColor);
+ const Graphic3d_Vec4 aRealColor = Graphic3d_Vec4 (anIntegerColor) / static_cast<Standard_ShortReal> (THE_MAX_INTEGER_COLOR_COMPONENT);
+ theColor = Quantity_ColorRGBA (Quantity_ColorRGBA::Convert_sRGB_To_LinearRGB (aRealColor));
return true;
}
if (theArgNb >= 3)
{
const Standard_Integer aNumberOfColorComponentsToParse = Min (theArgNb, theToParseAlpha ? 4 : 3);
- Standard_Integer aNumberOfColorComponentsParsed = aNumberOfColorComponentsToParse;
+ Standard_Integer aNumberOfColorComponentsParsed = aNumberOfColorComponentsToParse;
if (parseIntegerColor (aNumberOfColorComponentsParsed, theArgVec, theColor))
{
return aNumberOfColorComponentsParsed;
}
+ aNumberOfColorComponentsParsed = aNumberOfColorComponentsToParse;
if (parseRealColor (aNumberOfColorComponentsParsed, theArgVec, theColor))
{
return aNumberOfColorComponentsParsed;
//function : ParseLineType
//purpose :
//=======================================================================
-Standard_Boolean ViewerTest::ParseLineType (Standard_CString theArg,
- Aspect_TypeOfLine& theType)
+Standard_Boolean ViewerTest::ParseLineType (Standard_CString theArg,
+ Aspect_TypeOfLine& theType,
+ uint16_t& thePattern)
{
TCollection_AsciiString aTypeStr (theArg);
aTypeStr.LowerCase();
- if (aTypeStr == "empty")
+ if (aTypeStr == "empty"
+ || aTypeStr == "-1")
{
theType = Aspect_TOL_EMPTY;
+ thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType);
}
- else if (aTypeStr == "solid")
+ else if (aTypeStr == "solid"
+ || aTypeStr == "0")
{
theType = Aspect_TOL_SOLID;
+ thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType);
}
- else if (aTypeStr == "dot")
+ else if (aTypeStr == "dot"
+ || aTypeStr == "2")
{
theType = Aspect_TOL_DOT;
+ thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType);
}
- else if (aTypeStr == "dash")
+ else if (aTypeStr == "dash"
+ || aTypeStr == "1")
{
theType = Aspect_TOL_DASH;
+ thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType);
}
- else if (aTypeStr == "dotdash")
+ else if (aTypeStr == "dotdash"
+ || aTypeStr == "3")
{
theType = Aspect_TOL_DOTDASH;
+ thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType);
}
- else if (aTypeStr.IsIntegerValue())
+ else
{
- const int aTypeInt = aTypeStr.IntegerValue();
- if (aTypeInt < -1 || aTypeInt >= Aspect_TOL_USERDEFINED)
+ if (aTypeStr.StartsWith ("0x"))
+ {
+ aTypeStr = aTypeStr.SubString (3, aTypeStr.Length());
+ }
+
+ if (aTypeStr.Length() != 4
+ || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (1)))
+ || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (2)))
+ || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (3)))
+ || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (4))))
{
return Standard_False;
}
- theType = (Aspect_TypeOfLine )aTypeInt;
- }
- else
- {
- return Standard_False;
+
+ std::stringstream aStream;
+ aStream << std::setbase (16) << aTypeStr.ToCString();
+ if (aStream.fail())
+ {
+ return Standard_False;
+ }
+
+ Standard_Integer aNumber = -1;
+ aStream >> aNumber;
+ if (aStream.fail())
+ {
+ return Standard_False;
+ }
+
+ thePattern = (uint16_t )aNumber;
+ theType = Graphic3d_Aspects::DefaultLineTypeForPattern (thePattern);
}
return Standard_True;
}
{
theModel = Graphic3d_TOSM_FRAGMENT;
}
+ else if (aTypeStr == "pbr")
+ {
+ theModel = Graphic3d_TOSM_PBR;
+ }
+ else if (aTypeStr == "pbr_facet")
+ {
+ theModel = Graphic3d_TOSM_PBR_FACET;
+ }
else if (aTypeStr == "default"
|| aTypeStr == "def")
{
{
aParams.BufferType = Graphic3d_BT_RGB;
}
+ else if (aBufArg == "red")
+ {
+ aParams.BufferType = Graphic3d_BT_Red;
+ }
else if (aBufArg == "depth")
{
aParams.BufferType = Graphic3d_BT_Depth;
{
aParams.BufferType = Graphic3d_BT_RGB;
}
+ else if (anArg == "-red"
+ || anArg == "red")
+ {
+ aParams.BufferType = Graphic3d_BT_Red;
+ }
else if (anArg == "-depth"
|| anArg == "depth")
{
case Graphic3d_BT_RGBA: aFormat = Image_Format_RGBA; break;
case Graphic3d_BT_Depth: aFormat = Image_Format_GrayF; break;
case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF; break;
+ case Graphic3d_BT_Red: aFormat = Image_Format_Gray; break;
}
switch (aStereoPair)
Standard_Real LineWidth;
Standard_Integer ToSetTypeOfLine;
- Aspect_TypeOfLine TypeOfLine;
+ uint16_t StippleLinePattern;
Standard_Integer ToSetTypeOfMarker;
Aspect_TypeOfMarker TypeOfMarker;
ToSetLineWidth (0),
LineWidth (1.0),
ToSetTypeOfLine (0),
- TypeOfLine (Aspect_TOL_SOLID),
+ StippleLinePattern(0xFFFF),
ToSetTypeOfMarker (0),
TypeOfMarker (Aspect_TOM_PLUS),
ToSetMarkerSize (0),
std::cout << "Error: alpha cutoff value should be within (0; 1) range (specified " << AlphaCutoff << ")\n";
isOk = Standard_False;
}
- if (ToSetMaterial == 1
- && Material == Graphic3d_NOM_DEFAULT)
- {
- std::cout << "Error: unknown material " << MatName << ".\n";
- isOk = Standard_False;
- }
if (FreeBoundaryWidth <= 0.0
|| FreeBoundaryWidth > 10.0)
{
isOk = Standard_False;
}
if (ToSetShadingModel == 1
- && (ShadingModel < Graphic3d_TOSM_DEFAULT || ShadingModel > Graphic3d_TOSM_FRAGMENT))
+ && (ShadingModel < Graphic3d_TOSM_DEFAULT || ShadingModel > Graphic3d_TOSM_PBR_FACET))
{
std::cout << "Error: unknown shading model " << ShadingModelName << ".\n";
isOk = Standard_False;
|| theDrawer->HasOwnSeenLineAspect())
{
toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
- theDrawer->LineAspect()->SetTypeOfLine (TypeOfLine);
- theDrawer->WireAspect()->SetTypeOfLine (TypeOfLine);
- theDrawer->FreeBoundaryAspect()->SetTypeOfLine (TypeOfLine);
- theDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (TypeOfLine);
- theDrawer->SeenLineAspect()->SetTypeOfLine (TypeOfLine);
+ theDrawer->LineAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+ theDrawer->WireAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+ theDrawer->FreeBoundaryAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+ theDrawer->UnFreeBoundaryAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+ theDrawer->SeenLineAspect()->Aspect()->SetLinePattern (StippleLinePattern);
}
}
if (ToSetTypeOfMarker != 0)
//function : VAspects
//purpose :
//==============================================================================
-static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
+static Standard_Integer VAspects (Draw_Interpretor& theDI,
Standard_Integer theArgNb,
const char** theArgVec)
{
// parse syntax of legacy commands
bool toParseAliasArgs = false;
+ Standard_Boolean toDump = 0;
+ Standard_Boolean toCompactDump = 0;
+ Standard_Integer aDumpDepth = -1;
if (aCmdName == "vsetwidth")
{
if (aNames.IsEmpty()
aNames.Remove (aNames.Length());
isOk = Standard_True;
}
+ else if (Quantity_Color::ColorFromHex (aNames.Last().ToCString(), aChangeSet->Color))
+ {
+ aNames.Remove (aNames.Length());
+ isOk = Standard_True;
+ }
else if (aNames.Length() >= 3)
{
const char* anArgVec[3] =
return 1;
}
aChangeSet->ToSetMaterial = 1;
- aChangeSet->MatName = aNames.Last();
- aChangeSet->Material = Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString());
+ aChangeSet->MatName = aNames.Last();
aNames.Remove (aNames.Length());
+ if (!Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString(), aChangeSet->Material))
+ {
+ std::cout << "Syntax error: unknown material '" << aChangeSet->MatName << "'.\n";
+ return 1;
+ }
}
else if (aCmdName == "vunsetmaterial")
{
aChangeSet->FaceBoundaryColor = Quantity_Color (aNames.Value (3).IntegerValue() / 255.0,
aNames.Value (4).IntegerValue() / 255.0,
aNames.Value (5).IntegerValue() / 255.0,
- Quantity_TOC_RGB);
+ Quantity_TOC_sRGB);
aNames.Remove (5);
aNames.Remove (4);
aNames.Remove (3);
return 1;
}
Aspect_TypeOfLine aLineType = Aspect_TOL_EMPTY;
- if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aLineType))
+ uint16_t aLinePattern = 0xFFFF;
+ if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aLineType, aLinePattern))
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
}
+
if (anArg == "-setedgetype"
|| anArg == "-setedgestype"
|| anArg == "-edgetype"
|| anArg == "-edgestype"
|| aCmdName == "vsetedgetype")
{
- aChangeSet->TypeOfEdge = aLineType;
+ aChangeSet->TypeOfEdge = Graphic3d_Aspects::DefaultLineTypeForPattern (aLinePattern);
aChangeSet->ToSetTypeOfEdge = 1;
}
else if (anArg == "-setfaceboundarystyle"
|| anArg == "-boundarytype"
|| aCmdName == "vshowfaceboundary")
{
- aChangeSet->TypeOfFaceBoundaryLine = aLineType;
+ aChangeSet->TypeOfFaceBoundaryLine = Graphic3d_Aspects::DefaultLineTypeForPattern (aLinePattern);
aChangeSet->ToSetTypeOfFaceBoundaryLine = 1;
}
else
{
- aChangeSet->TypeOfLine = aLineType;
+ aChangeSet->StippleLinePattern = aLinePattern;
aChangeSet->ToSetTypeOfLine = 1;
}
}
return 1;
}
aChangeSet->ToSetMaterial = 1;
- aChangeSet->MatName = theArgVec[anArgIter];
- aChangeSet->Material = Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString());
+ aChangeSet->MatName = theArgVec[anArgIter];
+ if (!Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString(), aChangeSet->Material))
+ {
+ std::cout << "Syntax error: unknown material '" << aChangeSet->MatName << "'.\n";
+ return 1;
+ }
}
else if (anArg == "-unsetmat"
|| anArg == "-unsetmaterial")
aChangeSet->ToSetLineWidth = -1;
aChangeSet->LineWidth = 1.0;
aChangeSet->ToSetTypeOfLine = -1;
- aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
+ aChangeSet->StippleLinePattern = 0xFFFF;
aChangeSet->ToSetTypeOfMarker = -1;
aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
aChangeSet->ToSetMarkerSize = -1;
aChangeSet->ToSetTypeOfEdge = -1;
aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
}
+ else if (anArg == "-dumpjson")
+ {
+ toDump = Standard_True;
+ }
+ else if (anArg == "-dumpcompact")
+ {
+ toCompactDump = Standard_False;
+ if (++anArgIter >= theArgNb && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toCompactDump))
+ ++anArgIter;
+ }
+ else if (anArg == "-dumpdepth")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aDumpDepth = Draw::Atoi (theArgVec[anArgIter]);
+ }
else
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
aCtx->Redisplay (aPrs, Standard_False);
}
}
+ if (toDump)
+ {
+ Standard_SStream aStream;
+ aDrawer->DumpJson (aStream, aDumpDepth);
+
+ if (toCompactDump)
+ theDI << Standard_Dump::Text (aStream);
+ else
+ theDI << Standard_Dump::FormatJson (aStream);
+ }
return 0;
}
{
aPrs->SynchronizeAspects();
}
+
+ if (toDump)
+ {
+ Standard_SStream aStream;
+ aDrawer->DumpJson (aStream);
+
+ theDI << aName << ": \n";
+ theDI << Standard_Dump::FormatJson (aStream);
+ theDI << "\n";
+ }
}
}
return 0;
}
else if (theObj->Type() == AIS_KOI_Relation)
{
- // AIS_Dimention and AIS_Relation
- Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (theObj);
+ // PrsDim_Dimention and AIS_Relation
+ Handle(PrsDim_Relation) aRelation = Handle(PrsDim_Relation)::DownCast (theObj);
switch (aRelation->KindOfDimension())
{
- case AIS_KOD_PLANEANGLE: theDI << " AIS_AngleDimension"; break;
- case AIS_KOD_LENGTH: theDI << " AIS_Chamf2/3dDimension/AIS_LengthDimension"; break;
- case AIS_KOD_DIAMETER: theDI << " AIS_DiameterDimension"; break;
- case AIS_KOD_ELLIPSERADIUS: theDI << " AIS_EllipseRadiusDimension"; break;
- //case AIS_KOD_FILLETRADIUS: theDI << " AIS_FilletRadiusDimension "; break;
- case AIS_KOD_OFFSET: theDI << " AIS_OffsetDimension"; break;
- case AIS_KOD_RADIUS: theDI << " AIS_RadiusDimension"; break;
+ case PrsDim_KOD_PLANEANGLE: theDI << " PrsDim_AngleDimension"; break;
+ case PrsDim_KOD_LENGTH: theDI << " PrsDim_Chamf2/3dDimension/PrsDim_LengthDimension"; break;
+ case PrsDim_KOD_DIAMETER: theDI << " PrsDim_DiameterDimension"; break;
+ case PrsDim_KOD_ELLIPSERADIUS: theDI << " PrsDim_EllipseRadiusDimension"; break;
+ //case PrsDim_KOD_FILLETRADIUS: theDI << " PrsDim_FilletRadiusDimension "; break;
+ case PrsDim_KOD_OFFSET: theDI << " PrsDim_OffsetDimension"; break;
+ case PrsDim_KOD_RADIUS: theDI << " PrsDim_RadiusDimension"; break;
default: theDI << " UNKNOWN dimension"; break;
}
}
if(dimension_status == -1)
TheAISContext()->Erase(curio,Standard_False);
else {
- AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension();
- if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
- (dimension_status==1 && KOD != AIS_KOD_NONE))
+ PrsDim_KindOfDimension KOD = Handle(PrsDim_Relation)::DownCast (curio)->KindOfDimension();
+ if ((dimension_status==0 && KOD == PrsDim_KOD_NONE)||
+ (dimension_status==1 && KOD != PrsDim_KOD_NONE))
TheAISContext()->Erase(curio,Standard_False);
}
}
if(dimension_status == -1)
TheAISContext()->Display(curio,Standard_False);
else {
- AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension();
- if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
- (dimension_status==1 && KOD != AIS_KOD_NONE))
+ PrsDim_KindOfDimension KOD = Handle(PrsDim_Relation)::DownCast (curio)->KindOfDimension();
+ if ((dimension_status==0 && KOD == PrsDim_KOD_NONE)||
+ (dimension_status==1 && KOD != PrsDim_KOD_NONE))
TheAISContext()->Display(curio,Standard_False);
}
"\n\t\t: [-setMaterial MatName] [-unsetMaterial]"
"\n\t\t: [-setTransparency Transp] [-unsetTransparency]"
"\n\t\t: [-setWidth LineWidth] [-unsetWidth]"
- "\n\t\t: [-setLineType {solid|dash|dot|dotDash}] [-unsetLineType]"
+ "\n\t\t: [-setLineType {solid|dash|dot|dotDash|0xHexPattern}] [-unsetLineType]"
"\n\t\t: [-setMarkerType {.|+|x|O|xcircle|pointcircle|ring1|ring2|ring3|ball|ImagePath}]"
"\n\t\t: [-unsetMarkerType]"
"\n\t\t: [-setMarkerSize Scale] [-unsetMarkerSize]"
"\n\t\t: [-isoontriangulation 0|1]"
"\n\t\t: [-setMaxParamValue {value}]"
"\n\t\t: [-setSensitivity {selection_mode} {value}]"
- "\n\t\t: [-setShadingModel {color|flat|gouraud|phong}]"
+ "\n\t\t: [-setShadingModel {unlit|flat|gouraud|phong}]"
"\n\t\t: [-unsetShadingModel]"
"\n\t\t: [-setInterior {solid|hatch|hidenline|point}]"
"\n\t\t: [-unsetInterior] [-setHatch HatchStyle]"
"\n\t\t: [-setDrawEdges {0|1}] [-setEdgeType LineType] [-setEdgeColor R G B] [-setQuadEdges {0|1}]"
"\n\t\t: [-setDrawSilhouette {0|1}]"
"\n\t\t: [-setAlphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]"
+ "\n\t\t: [-dumpJson]"
+ "\n\t\t: [-dumpCompact {0|1}]"
+ "\n\t\t: [-dumpDepth depth]"
+ "\n\t\t: [-freeBoundary {off/on | 0/1}]"
"\n\t\t: Manage presentation properties of all, selected or named objects."
"\n\t\t: When -subshapes is specified than following properties will be"
"\n\t\t: assigned to specified sub-shapes."
"\n\t\t: When -defaults is specified than presentation properties will be"
"\n\t\t: assigned to all objects that have not their own specified properties"
"\n\t\t: and to all objects to be displayed in the future."
- "\n\t\t: If -defaults is used there should not be any objects' names and -subshapes specifier.",
+ "\n\t\t: If -defaults is used there should not be any objects' names and -subshapes specifier."
+ "\n\t\t: See also vlistcolors and vlistmaterials to list named colors and materials"
+ "\n\t\t: accepted by arguments -setMaterial and -setColor",
__FILE__,VAspects,group);
theCommands.Add("vsetcolor",
#include <DBRep.hxx>
#include <TopoDS_Face.hxx>
#include <gp_Pln.hxx>
-#include <AIS_KindOfSurface.hxx>
#include <BRepOffsetAPI_DraftAngle.hxx>
#include <Precision.hxx>
#include <BRepAlgo.hxx>
#include <OSD_Environment.hxx>
#include <DrawTrSurf.hxx>
-//#include <DbgTools.hxx>
-//#include <FeatAlgo_MakeLinearForm.hxx>
-
-
-
//=======================================================================
//function : IsValid
anAngle = 2*M_PI * anAngle / 360.0;
gp_Pln aPln;
Handle( Geom_Surface )aSurf;
- AIS_KindOfSurface aSurfType;
+ PrsDim_KindOfSurface aSurfType;
Standard_Real Offset;
gp_Dir aDir;
if(argc > 4) { // == 5
}
TopoDS_Face face2 = TopoDS::Face(Plane);
- if(!AIS::GetPlaneFromFace(face2, aPln, aSurf, aSurfType, Offset))
+ if(!PrsDim::GetPlaneFromFace(face2, aPln, aSurf, aSurfType, Offset))
{
di << "TEST : Can't find plane\n";
return 1;