From: isn Date: Thu, 17 Jan 2019 15:18:20 +0000 (+0300) Subject: lot 3 : curve creator : allow to move points on spline curve X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FBR_H2018_2;p=modules%2Fgeom.git lot 3 : curve creator : allow to move points on spline curve --- diff --git a/src/CurveCreator/CurveCreator_Curve.cxx b/src/CurveCreator/CurveCreator_Curve.cxx index ca421ef79..3c83e673e 100644 --- a/src/CurveCreator/CurveCreator_Curve.cxx +++ b/src/CurveCreator/CurveCreator_Curve.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -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(myAISShape); std::map::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 ); diff --git a/src/CurveCreator/CurveCreator_Curve.hxx b/src/CurveCreator/CurveCreator_Curve.hxx index 10bbc1870..22caf3f77 100644 --- a/src/CurveCreator/CurveCreator_Curve.hxx +++ b/src/CurveCreator/CurveCreator_Curve.hxx @@ -356,7 +356,7 @@ public: Quantity_Color myPointAspectColor; //Quantity_Color myCurveColor; double myLineWidth; - NCollection_IndexedDataMap mySect2Wire; + NCollection_IndexedDataMap mySect2Shape; std::vector myCurSectInd; private: diff --git a/src/CurveCreator/CurveCreator_Utils.cxx b/src/CurveCreator/CurveCreator_Utils.cxx index 24c60320d..ee4ea6a84 100644 --- a/src/CurveCreator/CurveCreator_Utils.cxx +++ b/src/CurveCreator/CurveCreator_Utils.cxx @@ -295,11 +295,12 @@ TopoDS_Wire CurveCreator_Utils::ConstructWire( //======================================================================= void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, TopoDS_Shape& theShape, - NCollection_IndexedDataMap* theSect2Wire ) + NCollection_IndexedDataMap* 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); } } } diff --git a/src/CurveCreator/CurveCreator_Utils.hxx b/src/CurveCreator/CurveCreator_Utils.hxx index f773f2317..3da356778 100644 --- a/src/CurveCreator/CurveCreator_Utils.hxx +++ b/src/CurveCreator/CurveCreator_Utils.hxx @@ -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* Sect2Wire = NULL); + NCollection_IndexedDataMap* Sect2Shape = NULL); /** * Generates a curve from a shape. diff --git a/src/CurveCreator/CurveCreator_Widget.cxx b/src/CurveCreator/CurveCreator_Widget.cxx index 074f03577..07b610080 100644 --- a/src/CurveCreator/CurveCreator_Widget.cxx +++ b/src/CurveCreator/CurveCreator_Widget.cxx @@ -1174,7 +1174,7 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven for (int i=0; imyCurSectInd.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());