return true;
}
+//=======================================================================
+//function : SetColor
+//purpose :
+//=======================================================================
void AIS_PointCloud::SetColor (const Quantity_NameOfColor theColor)
{
SetColor (Quantity_Color(theColor));
}
+//=======================================================================
+//function : SetColor
+//purpose :
+//=======================================================================
void AIS_PointCloud::SetColor (const Quantity_Color &theColor)
{
if (!myDrawer->HasPointAspect())
hasOwnColor = Standard_True;
myOwnColor = theColor;
-
- Handle(Graphic3d_AspectMarker3d) aPointAspect = myDrawer->PointAspect()->Aspect();
-
- const Handle(Prs3d_Presentation)& aPrs = Presentations().Value (1).Presentation()->Presentation();
-
- // Set aspect for presentation
- aPrs->SetPrimitivesAspect (aPointAspect);
-
- const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().First();
-
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
- {
- aGroup->SetGroupPrimitivesAspect (aPointAspect);
- }
}
//=======================================================================
if (myPoints.IsNull() || !myPoints->IsValid()) return;
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPresentation);
-
- /************************************
- static Handle(Graphic3d_AspectMarker3d) PtA = new Graphic3d_AspectMarker3d();
- PtA->SetType(Aspect_TOM_POINT);
- PtA->SetScale(1.);
- Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
- TheGroup->SetPrimitivesAspect(PtA);
- Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
- aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
- TheGroup->AddPrimitiveArray (aPoint);
- ******************************/
-
if (Attributes()->HasPointAspect())
{
aGroup->SetPrimitivesAspect (Attributes()->PointAspect()->Aspect());
aGroup->AddPrimitiveArray (myPoints);
}
+//=======================================================================
+//function : ComputeSelection
+//purpose :
+//=======================================================================
void AIS_PointCloud::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
const Standard_Integer /*aMode*/)
{
return 0;
}
+//! Auxilarily function.
+//! Create random float number in range from theMin to theMax.
+static Standard_Real RandomReal (const Standard_Real theMin, const Standard_Real theMax)
+{
+ return theMin + (theMax - theMin) * Standard_Real(rand()) / RAND_MAX;
+}
+
//=======================================================================
//function : VPointCloud
//purpose : Create interactive object for arbitary set of points.
//=======================================================================
-static Standard_Integer VPointCloud (Draw_Interpretor&,
+static Standard_Integer VPointCloud (Draw_Interpretor& /*theDI*/,
Standard_Integer theArgNum,
const char** theArgs)
{
aMode = anArg.Token ("=", 2).IntegerValue();
if (aMode != 0 && aMode != 1)
{
- std::cerr << "Wrong argument : " << anArg << "\n";
+ std::cerr << "Wrong argument : " << anArg << std::endl;
return 1;
}
}
// Set array of points in point cloud object
aPointCloud->SetPoints (anArrayPoints);
}
- /*else if (aMode == 1)
+ else if (aMode == 1)
{
Handle(AIS_ArrayOfPnt) aCoords = new AIS_ArrayOfPnt (1, aNumberOfPoints);
Handle(AIS_ArrayOfPnt) aColors = new AIS_ArrayOfPnt (1, aNumberOfPoints);
}
// Set coordinates and colors
aPointCloud->SetPoints (aCoords, aColors, aHasColor);
- }*/
-
- //std::cout << aPointCloud->Attributes()->HasLocalAttributes()
+ }
// Set point aspect for attributes of interactive object
Aspect_TypeOfMarker anAMarkerType = aMarkerType >= 0 ? (Aspect_TypeOfMarker )aMarkerType : Aspect_TOM_POINT;
return 0;
}
-//=======================================================================
-//function : VPointCloudSetColor
-//purpose : Sets the color for point cloud.
-//=======================================================================
-static Standard_Integer VPointCloudSetColor (Draw_Interpretor&,
- Standard_Integer theArgNum,
- const char** theArgs)
-{
- // Check arguments
- if (theArgNum < 3)
- {
- std::cout << theArgs[0] << " error: wrong number of parameters. Type 'help "
- << theArgs[0] << "' for more information.\n";
- return 1;
- }
-
- // Check AIS context
- Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
- if (anAISContext.IsNull())
- {
- std::cerr << "Call 'vinit' before!" << std::endl;
- return 1;
- }
-
- Standard_Integer anArgIter = 1;
-
- // Find an interactive object in map of AIS context
- TCollection_AsciiString aName (theArgs[anArgIter++]);
- Handle(AIS_InteractiveObject) anInterObject = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
- if (anInterObject.IsNull())
- {
- std::cout << "Not an AIS interactive object!" << std::endl;
- return 1;
- }
-
- // Get color name
- const TCollection_AsciiString aColorName (theArgs[anArgIter++]);
- Quantity_NameOfColor aNameOfColor = ViewerTest::GetColorFromName (aColorName.ToCString());
-
- // Set color
- anInterObject->SetColor (aNameOfColor);
-
- // Update context current viewer
- anAISContext->UpdateCurrentViewer();
-}
-
//=======================================================================
//function : ObjectsCommands
//purpose :
" [FileName=PointCloudFile]"
"\n\t\t: Create an interactive object for arbitary set of points.",
__FILE__, VPointCloud, group);
- theCommands.Add ("vpcsetcolor",
- "vpcsetcolor usage:\n"
- "vpcsetcolor PointCloudObjectName [ColorName=GREEN]"
- "\n\t\t: Set color for point cloud interactive object.",
- __FILE__, VPointCloudSetColor, group);
}