myImage->SetPixelColor (theCol, theRow, aColor);
}
};
+
+ //! Help class for filling pixel with normal direction value.
+ class SurfaceNormalFiller : public SelectMgr_SelectionImageFiller
+ {
+ public:
+ SurfaceNormalFiller (Image_PixMap& thePixMap,
+ SelectMgr_ViewerSelector* theSelector)
+ : SelectMgr_SelectionImageFiller (thePixMap, theSelector) {}
+
+ virtual void Fill (const Standard_Integer theCol,
+ const Standard_Integer theRow,
+ const Standard_Integer thePicked) Standard_OVERRIDE
+ {
+ if (thePicked <= 0
+ || thePicked > myMainSel->NbPicked())
+ {
+ myImage->SetPixelColor (theCol, theRow, Quantity_NOC_BLACK);
+ }
+ else
+ {
+ const Handle(Select3D_SensitiveEntity)& aPickedEntity = myMainSel->PickedEntity (thePicked);
+ SelectBasics_PickResult aPickResult;
+ aPickedEntity->Matches (myMainSel->GetManager(), aPickResult);
+ Graphic3d_Vec3 aNormal = aPickResult.SurfaceNormal();
+ aNormal.Normalize();
+ myImage->SetPixelColor (theCol, theRow, Quantity_ColorRGBA (aNormal.x() * 0.5f + 0.5f,
+ aNormal.y() * 0.5f + 0.5f,
+ aNormal.z() * 0.5f + 0.5f, 1.0f));
+ }
+ }
+ };
}
// =======================================================================
{
return new GeneratedSelModeColorFiller (thePixMap, theSelector);
}
+ case StdSelect_TypeOfSelectionImage_SurfaceNormal:
+ {
+ return new SurfaceNormalFiller (thePixMap, theSelector);
+ }
}
return Handle(SelectMgr_SelectionImageFiller)();
}
StdSelect_TypeOfSelectionImage_ColoredDetectedObject, //!< color of detected object
StdSelect_TypeOfSelectionImage_ColoredEntity, //!< random color for each entity
StdSelect_TypeOfSelectionImage_ColoredOwner, //!< random color for each owner
- StdSelect_TypeOfSelectionImage_ColoredSelectionMode //!< color of selection mode
+ StdSelect_TypeOfSelectionImage_ColoredSelectionMode, //!< color of selection mode
+ StdSelect_TypeOfSelectionImage_SurfaceNormal //!< normal direction values
};
#endif
{
aType = StdSelect_TypeOfSelectionImage_ColoredSelectionMode;
}
+ else if (aValue == "surfnormal"
+ || aValue == "surfacenormal"
+ || aValue == "normal")
+ {
+ aType = StdSelect_TypeOfSelectionImage_SurfaceNormal;
+ }
}
else if (aParam == "-picked"
|| aParam == "-pickeddepth"
"\n\t\t: object color of detected object"
"\n\t\t: owner color of detected owner"
"\n\t\t: selMode color of selection mode"
- "\n\t\t: entity color of etected entity",
+ "\n\t\t: entity color of etected entity"
+ "\n\t\t: surfNormal normal direction values",
__FILE__, VDumpSelectionImage, group);
theCommands.Add ("vviewcube",
011 vertex_wire
012 wire
013 wire_solid
+014 sphere
--- /dev/null
+vinit View1 -height 400 -width 600
+set subgroup "sphere"
--- /dev/null
+puts "================================="
+puts "000032366: Visualization, SelectMgr_ViewerSelector3d::ToPixMap() - add option dumping surface normals"
+puts "Generating images based on detection of Select3D_SenstiveSphere"
+puts "================================="
+
+psphere s 1
+vdisplay -dispMode 1 s
+vfit
+vseldump $imagedir/${casename}_selmode_0.png -type surfNormal
+vselmode 1 1
+vseldump $imagedir/${casename}_selmode_1.png -type surfNormal
+vselmode 4 1
+vseldump $imagedir/${casename}_selmode_4.png -type surfNormal
--- /dev/null
+puts "================================="
+puts "0032182: Visualization - add Select3D_SensitiveSphere"
+puts "Tests rectangular selection of Select3D_SenstiveSphere"
+puts "================================="
+
+psphere s1 1
+psphere s2 1
+psphere s3 1
+psphere s4 1
+ttranslate s1 2 2 0
+ttranslate s2 2 -2 0
+ttranslate s3 -2 2 0
+ttranslate s4 -2 -2 0
+vdisplay -dispMode 1 s1 s2 s3 s4
+vfit
+vselect 15 15 585 385
+if { ![string match "*Selected*" [vstate s1]] ||
+ ![string match "*Selected*" [vstate s2]] ||
+ ![string match "*Selected*" [vstate s3]] ||
+ ![string match "*Selected*" [vstate s4]]} { puts "Error: all spheres should be selected" }
+vselect 15 15 585 385 -allowoverlap 1
+if { ![string match "*Selected*" [vstate s1]] ||
+ ![string match "*Selected*" [vstate s2]] ||
+ ![string match "*Selected*" [vstate s3]] ||
+ ![string match "*Selected*" [vstate s4]]} { puts "Error: all spheres should be selected" }
+vselect 50 135 300 400
+if { [string match "*Selected*" [vstate s1]] ||
+ [string match "*Selected*" [vstate s2]] ||
+ [string match "*Selected*" [vstate s3]] ||
+ ![string match "*Selected*" [vstate s4]]} { puts "Error: only sphere s4 should be selected" }
+vselect 0 0 300 400 -allowoverlap 1
+if { [string match "*Selected*" [vstate s1]] ||
+ ![string match "*Selected*" [vstate s2]] ||
+ ![string match "*Selected*" [vstate s3]] ||
+ ![string match "*Selected*" [vstate s4]]} { puts "Error: spheres s2, s3 and s4 should be selected" }
+vright
+vselect 80 100 300 300
+if { [string match "*Selected*" [vstate s1]] ||
+ ![string match "*Selected*" [vstate s2]] ||
+ [string match "*Selected*" [vstate s3]] ||
+ ![string match "*Selected*" [vstate s4]]} { puts "Error: spheres s1 and s3 should be unselected" }
+vselect 380 170 451 241 -allowoverlap 1
+if { ![string match "*Selected*" [vstate s1]] ||
+ [string match "*Selected*" [vstate s2]] ||
+ ![string match "*Selected*" [vstate s3]] ||
+ [string match "*Selected*" [vstate s4]]} { puts "Error: spheres s1 and s3 should be selected" }
+vselect 0 400 600 200
+if { [string match "*Selected*" [vstate s1]] ||
+ [string match "*Selected*" [vstate s2]] ||
+ [string match "*Selected*" [vstate s3]] ||
+ [string match "*Selected*" [vstate s4]]} { puts "Error: all spheres should be unselected" }
+vselect 0 400 600 200 -allowoverlap 1
+if { ![string match "*Selected*" [vstate s1]] ||
+ ![string match "*Selected*" [vstate s2]] ||
+ ![string match "*Selected*" [vstate s3]] ||
+ ![string match "*Selected*" [vstate s4]]} { puts "Error: all spheres should be selected" }
--- /dev/null
+puts "================================="
+puts "0032182: Visualization - add Select3D_SensitiveSphere"
+puts "Tests selection of Select3D_SenstiveSphere"
+puts "================================="
+
+psphere s 1
+vdisplay -dispMode 1 s
+vfit
+vselect 300 200
+if { ![string match "*Selected*" [vstate s]] } { puts "Error: sphere should be selected" }
+vselect 195 110
+if { [string match "*Selected*" [vstate s]] } { puts "Error: sphere should be unselected" }
+vselect 390 110
+if { [string match "*Selected*" [vstate s]] } { puts "Error: sphere should be unselected" }
+vselect 390 282
+if { [string match "*Selected*" [vstate s]] } { puts "Error: sphere should be unselected" }
+vselect 213 291
+if { [string match "*Selected*" [vstate s]] } { puts "Error: sphere should be unselected" }
+vselect 300 200 -allowoverlap 1
+if { ![string match "*Selected*" [vstate s]] } { puts "Error: sphere should be selected" }
+vselect 195 110 -allowoverlap 1
+if { [string match "*Selected*" [vstate s]] } { puts "Error: sphere should be unselected" }