View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0027790 | Community | OCCT:Modeling Data | public | 2016-08-18 13:21 | 2016-08-19 16:06 |
| Reporter | aothms | Assigned To | bugmaster | ||
| Priority | normal | Severity | minor | ||
| Status | closed | Resolution | no change required | ||
| Platform | Windows | OS | VC++ 2015 | ||
| Product Version | 7.0.0 | ||||
| Summary | 0027790: Location not read for root TopoDS_Shape from BRepTools_ShapeSet | ||||
| Description | Consider the C++ code below. I would expect the TopoDS_Face to be read back from a BRepTools_ShapeSet including the location. However, the location for a root shape is not automatically applied. Only for child shapes, e.g. when the face is added to a compound, the location is restored. The script outputs: Original plane at: (0 0 1) Read plane at: (0 0 0) Read plane from compound at: (0 0 1) Whereas I would expect: Original plane at: (0 0 1) Read plane at: (0 0 1) Read plane from compound at: (0 0 1) If one knows the index in the BRepTools_ShapeSet::Locations() one can restore the location manually. But only in trivial cases I am able to find the correct location from the set. #include <gp_Pln.hxx> #include <Geom_Plane.hxx> #include <BRep_Tool.hxx> #include <BRepTools_ShapeSet.hxx> #include <TopoDS.hxx> #include <TopoDS_Face.hxx> #include <TopoDS_Compound.hxx> #include <TopoDS_Iterator.hxx> #include <BRepBuilderAPI_MakeFace.hxx> int main(int argc, char** argv) { TopoDS_Face face = BRepBuilderAPI_MakeFace(gp_Pln()).Face(); gp_Trsf trsf; trsf.SetTranslation(gp::DZ()); face.Move(trsf); std::cerr << "Original plane at:" << std::endl; const gp_Pnt& p = Handle_Geom_Plane::DownCast( BRep_Tool::Surface(face) )->Pln().Location(); std::cerr << "(" << p.X() << " " << p.Y() << " " << p.Z() << ")" << std::endl; { std::stringstream stream; { BRepTools_ShapeSet shapes; shapes.Add(face); shapes.Write(stream); } { BRepTools_ShapeSet shapes; shapes.Read(stream); std::cerr << "Read plane at:" << std::endl; const gp_Pnt& p = Handle_Geom_Plane::DownCast( BRep_Tool::Surface(TopoDS::Face(shapes.Shape(1))) )->Pln().Location(); std::cerr << "(" << p.X() << " " << p.Y() << " " << p.Z() << ")" << std::endl; } } { BRep_Builder b; TopoDS_Compound compound; b.MakeCompound(compound); b.Add(compound, face); std::stringstream stream; { BRepTools_ShapeSet shapes; shapes.Add(compound); shapes.Write(stream); } { BRepTools_ShapeSet shapes; shapes.Read(stream); TopoDS_Face face = TopoDS::Face(TopoDS_Iterator(shapes.Shape(2)).Value()); std::cerr << "Read plane from compound at:" << std::endl; const gp_Pnt& p = Handle_Geom_Plane::DownCast( BRep_Tool::Surface(face) )->Pln().Location(); std::cerr << "(" << p.X() << " " << p.Y() << " " << p.Z() << ")" << std::endl; } } std::cin.get(); } | ||||
| Steps To Reproduce | Run the attached C++ code and observe that the face location is not restored. The executable will output: Original plane at: (0 0 1) Read plane at: (0 0 0) Read plane from compound at: (0 0 1) | ||||
| Additional information and documentation updates | If this is the intended behaviour, documentation needs to be more clearly updated on this fact and a reference on how to find the original location from the TopTools_LocationSet would be beneficial. | ||||
| Tags | No tags attached. | ||||
| Test case number | |||||
|
|
|
face_serialization.cpp (1,780 bytes) |
|
|
BRepTools_ShapeSet is a low-level tool that is used for serialization of a TopoDS_Shape to/from a stream in the user-level API provided by the static methods Read/Write of the class BRepTools. I wonder why don't you use BRepTools::Read and Write. Do you have any serious reason to use low-level methods? |
|
|
BTW, of course you are getting wrong result because of you are using the class BRepTools_ShapeSet in a wrong way. |
|
|
Thanks for clarifying. While I was aware of BRepTools::Read and Write I didn't know that BRepTools_ShapeSet was considered more low level. I can confirm that with your suggestion the code works as expected. #include <gp_Pln.hxx> #include <Geom_Plane.hxx> #include <BRep_Tool.hxx> #include <BRepTools.hxx> #include <BRepTools_ShapeSet.hxx> #include <TopoDS.hxx> #include <TopoDS_Face.hxx> #include <TopoDS_Compound.hxx> #include <TopoDS_Iterator.hxx> #include <BRepBuilderAPI_MakeFace.hxx> int main(int argc, char** argv) { TopoDS_Face face = BRepBuilderAPI_MakeFace(gp_Pln()).Face(); gp_Trsf trsf; trsf.SetTranslation(gp::DZ()); face.Move(trsf); std::cerr << "Original plane at:" << std::endl; const gp_Pnt& p = Handle_Geom_Plane::DownCast( BRep_Tool::Surface(face) )->Pln().Location(); std::cerr << "(" << p.X() << " " << p.Y() << " " << p.Z() << ")" << std::endl; { std::stringstream stream; { // BRepTools_ShapeSet shapes; // shapes.Add(face); // shapes.Write(stream); BRepTools::Write(face, stream); } { // BRepTools_ShapeSet shapes; // shapes.Read(stream); // TopoDS_Face face = TopoDS::Face(shapes.Shape(1)); BRep_Builder B; TopoDS_Face face; BRepTools::Read(face, stream, B); std::cerr << "Read plane at:" << std::endl; const gp_Pnt& p = Handle_Geom_Plane::DownCast( BRep_Tool::Surface(face) )->Pln().Location(); std::cerr << "(" << p.X() << " " << p.Y() << " " << p.Z() << ")" << std::endl; } } { BRep_Builder b; TopoDS_Compound compound; b.MakeCompound(compound); b.Add(compound, face); std::stringstream stream; { // BRepTools_ShapeSet shapes; // shapes.Add(face); // shapes.Write(stream); BRepTools::Write(compound, stream); } { // BRepTools_ShapeSet shapes; // shapes.Read(stream); // TopoDS_Face face = TopoDS::Face(TopoDS_Iterator(shapes.Shape(2)).Value()); BRep_Builder B; TopoDS_Compound compound; BRepTools::Read(compound, stream, B); TopoDS_Face face = TopoDS::Face(TopoDS_Iterator(compound).Value()); std::cerr << "Read plane from compound at:" << std::endl; const gp_Pnt& p = Handle_Geom_Plane::DownCast( BRep_Tool::Surface(face) )->Pln().Location(); std::cerr << "(" << p.X() << " " << p.Y() << " " << p.Z() << ")" << std::endl; } } std::cin.get(); } |
|
|
Can be closed. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2016-08-18 13:21 | aothms | New Issue | |
| 2016-08-18 13:21 | aothms | Assigned To | => msv |
| 2016-08-18 13:21 | aothms | File Added: face_serialization.cpp | |
| 2016-08-18 18:29 |
|
Note Added: 0056834 | |
| 2016-08-18 18:29 |
|
Assigned To | msv => aothms |
| 2016-08-18 18:29 |
|
Status | new => feedback |
| 2016-08-18 18:30 |
|
Note Added: 0056835 | |
| 2016-08-19 12:00 | aothms | Note Added: 0056859 | |
| 2016-08-19 12:02 | aothms | Note Added: 0056860 | |
| 2016-08-19 12:02 | aothms | Assigned To | aothms => msv |
| 2016-08-19 12:15 |
|
Assigned To | msv => bugmaster |
| 2016-08-19 12:15 |
|
Resolution | open => no change required |
| 2016-08-19 16:06 | bugmaster | Status | feedback => closed |