mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-25 17:00:35 +05:00
lot 3 : curve creator : allow to move points on spline curve
This commit is contained in:
parent
0d3e4210ae
commit
e014eecb1b
@ -31,6 +31,7 @@
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
@ -1063,25 +1064,29 @@ Handle(TColgp_HArray1OfPnt) CurveCreator_Curve::GetDifferentPoints( int theISect
|
||||
CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
|
||||
return aSection ? aSection->GetDifferentPoints( (int)myDimension ) : Handle(TColgp_HArray1OfPnt)();
|
||||
}
|
||||
|
||||
void CurveCreator_Curve::constructAISObject()
|
||||
{
|
||||
//DEBTRACE("constructAISObject");
|
||||
TopoDS_Shape aShape;
|
||||
mySect2Wire.Clear();
|
||||
CurveCreator_Utils::constructShape( this, aShape, &mySect2Wire );
|
||||
mySect2Shape.Clear();
|
||||
CurveCreator_Utils::constructShape( this, aShape, &mySect2Shape );
|
||||
myAISShape = new AIS_ColoredShape( aShape );
|
||||
AIS_ColoredShape* AISColoredShape = dynamic_cast<AIS_ColoredShape*>(myAISShape);
|
||||
|
||||
std::map<int, TopoDS_Shape>::iterator it;
|
||||
|
||||
//for ( it = mySect2Wire.begin(); it != mySect2Wire.end(); it++ )
|
||||
for (int i = 1; i <= mySect2Wire.Extent(); i++ )
|
||||
//for ( it = mySect2Shape.begin(); it != mySect2Shape.end(); it++ )
|
||||
for (int i = 1; i <= mySect2Shape.Extent(); i++ )
|
||||
{
|
||||
CurveCreator_Section* aSect = (CurveCreator_Section*)getSection(mySect2Wire.FindKey(i));
|
||||
CurveCreator_Section* aSect = (CurveCreator_Section*)getSection(mySect2Shape.FindKey(i));
|
||||
Quantity_Color aColor = aSect->myColor;
|
||||
const TopoDS_Shape& aWire = mySect2Wire.FindFromIndex(i);
|
||||
AISColoredShape->SetCustomColor(aWire, aColor);
|
||||
const TopoDS_Shape& aShape = mySect2Shape.FindFromIndex(i); //should contain: one wire + vertices
|
||||
TopoDS_Iterator it(aShape);
|
||||
for (;it.More();it.Next())
|
||||
{
|
||||
if (it.Value().ShapeType() == TopAbs_WIRE)
|
||||
AISColoredShape->SetCustomColor(it.Value(), aColor);
|
||||
}
|
||||
}
|
||||
|
||||
// myAISShape->SetColor( myCurveColor );
|
||||
|
@ -356,7 +356,7 @@ public:
|
||||
Quantity_Color myPointAspectColor;
|
||||
//Quantity_Color myCurveColor;
|
||||
double myLineWidth;
|
||||
NCollection_IndexedDataMap<int, TopoDS_Shape> mySect2Wire;
|
||||
NCollection_IndexedDataMap<int, TopoDS_Shape> mySect2Shape;
|
||||
std::vector<int> myCurSectInd;
|
||||
|
||||
private:
|
||||
|
@ -295,11 +295,12 @@ TopoDS_Wire CurveCreator_Utils::ConstructWire(
|
||||
//=======================================================================
|
||||
void CurveCreator_Utils::constructShape(
|
||||
const CurveCreator_ICurve* theCurve, TopoDS_Shape& theShape,
|
||||
NCollection_IndexedDataMap<int, TopoDS_Shape>* theSect2Wire )
|
||||
NCollection_IndexedDataMap<int, TopoDS_Shape>* theSect2Shape )
|
||||
{
|
||||
BRep_Builder aBuilder;
|
||||
TopoDS_Compound aShape;
|
||||
aBuilder.MakeCompound(aShape);
|
||||
|
||||
const int aSectionCount = theCurve->getNbSections();
|
||||
for (int aSectionI = 0; aSectionI < aSectionCount; ++aSectionI)
|
||||
{
|
||||
@ -314,10 +315,18 @@ void CurveCreator_Utils::constructShape(
|
||||
const int aPointCount = aPoints->Length();
|
||||
const bool isClosed = theCurve->isClosed(aSectionI);
|
||||
|
||||
TopoDS_Compound ShapeWireWithV;
|
||||
if (theSect2Shape)
|
||||
aBuilder.MakeCompound(ShapeWireWithV);
|
||||
|
||||
// Add the vertices to the shape.
|
||||
for (Standard_Integer aPN = 1; aPN <= aPointCount; ++aPN)
|
||||
{
|
||||
aBuilder.Add(aShape, BRepBuilderAPI_MakeVertex(aPoints->Value(aPN)));
|
||||
TopoDS_Vertex V;
|
||||
aBuilder.MakeVertex(V,aPoints->Value(aPN),Precision::Confusion());
|
||||
aBuilder.Add(aShape, V);
|
||||
if (theSect2Shape)
|
||||
aBuilder.Add(ShapeWireWithV, V);
|
||||
}
|
||||
|
||||
// Add the wire to the shape.
|
||||
@ -327,10 +336,10 @@ void CurveCreator_Utils::constructShape(
|
||||
if (!aWire.IsNull())
|
||||
{
|
||||
aBuilder.Add(aShape, aWire);
|
||||
if (theSect2Wire)
|
||||
if (theSect2Shape)
|
||||
{
|
||||
//CurveCreator_Section* aSection = (CurveCreator_Section*)theCurve->getSection(aSectionI);
|
||||
(*theSect2Wire).Add(aSectionI, aWire);
|
||||
aBuilder.Add(ShapeWireWithV, aWire);
|
||||
(*theSect2Shape).Add(aSectionI, ShapeWireWithV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,11 +87,11 @@ public:
|
||||
* Generates shape on the curve
|
||||
* \param theCurve a curve object, that contains data
|
||||
* \param theShape a generated shape
|
||||
* \param Sect2Wire optional out map: section to constructed wire
|
||||
* \param Sect2Shape optional out map: section to constructed shape (wire+vertices)
|
||||
*/
|
||||
CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
|
||||
TopoDS_Shape& theShape,
|
||||
NCollection_IndexedDataMap<int, TopoDS_Shape>* Sect2Wire = NULL);
|
||||
NCollection_IndexedDataMap<int, TopoDS_Shape>* Sect2Shape = NULL);
|
||||
|
||||
/**
|
||||
* Generates a curve from a shape.
|
||||
|
@ -1174,7 +1174,7 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven
|
||||
for (int i=0; i<Curve->myCurSectInd.size(); i++)
|
||||
{
|
||||
int sectInd = Curve->myCurSectInd[i];
|
||||
const TopoDS_Shape& W = Curve->mySect2Wire(sectInd+1);
|
||||
const TopoDS_Shape& W = Curve->mySect2Shape(sectInd+1);
|
||||
TopExp_Explorer exp(W, TopAbs_VERTEX);
|
||||
for (;exp.More();exp.Next())
|
||||
filter->AddShape(exp.Current());
|
||||
|
Loading…
Reference in New Issue
Block a user