]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
lot 3 : curve creator : allow to move points on spline curve BR_H2018_2
authorisn <isn@opencascade.com>
Thu, 17 Jan 2019 15:18:20 +0000 (18:18 +0300)
committerisn <isn@opencascade.com>
Thu, 17 Jan 2019 16:16:02 +0000 (19:16 +0300)
src/CurveCreator/CurveCreator_Curve.cxx
src/CurveCreator/CurveCreator_Curve.hxx
src/CurveCreator/CurveCreator_Utils.cxx
src/CurveCreator/CurveCreator_Utils.hxx
src/CurveCreator/CurveCreator_Widget.cxx

index ca421ef79f05c0bc07375b7572522e73617a297b..3c83e673ee65126d7672c59e3bd6de8e05e44d7e 100644 (file)
@@ -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 );
index 10bbc187084c10fa95580a180b6a7cb87e0a8459..22caf3f77cae81c0dae456f7f0ccf19dbf511d3a 100644 (file)
@@ -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:
index 24c60320d5452165f1085e318d2cdb2054349cb5..ee4ea6a84300fec7bae7040ce14520cc3321c215 100644 (file)
@@ -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);
       }
     }
   }
index f773f23171208b21f38150e7995043d3e471523d..3da356778d345f12831f28ceabcbbe844b0970e2 100644 (file)
@@ -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.
index 074f035778f32ef8b148388b257920a4b9fb0ae0..07b6100800a2495776a228fa0fe235d2eb21096d 100644 (file)
@@ -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());