#ifndef MODELREFINE_H #define MODELREFINE_H #include #include #include #include #include #include #include #include #include #include #include #include #include namespace ModelRefine { typedef std::vector FaceVectorType; typedef std::vector EdgeVectorType; typedef std::vector ShapeVectorType; typedef std::pair ShapePairType; void getFaceEdges(const TopoDS_Face &face, EdgeVectorType &edges); void boundaryEdges(const FaceVectorType &faces, EdgeVectorType &edgesOut); TopoDS_Shell removeFaces(const TopoDS_Shell &shell, const FaceVectorType &faces); class FaceTypedBase { private: FaceTypedBase(){} protected: FaceTypedBase(const GeomAbs_SurfaceType &typeIn){surfaceType = typeIn;} public: virtual bool isEqual(const TopoDS_Face &faceOne, const TopoDS_Face &faceTwo) const = 0; virtual GeomAbs_SurfaceType getType() const = 0; virtual TopoDS_Face buildFace(const FaceVectorType &faces) const = 0; static GeomAbs_SurfaceType getFaceType(const TopoDS_Face &faceIn); protected: virtual void boundarySplit(const FaceVectorType &facesIn, std::vector &boundariesOut) const; GeomAbs_SurfaceType surfaceType; }; class FaceTypedPlane : public FaceTypedBase { private: FaceTypedPlane(); public: virtual bool isEqual(const TopoDS_Face &faceOne, const TopoDS_Face &faceTwo) const; virtual GeomAbs_SurfaceType getType() const; virtual TopoDS_Face buildFace(const FaceVectorType &faces) const; friend FaceTypedPlane& getPlaneObject(); }; FaceTypedPlane& getPlaneObject(); class FaceTypedCylinder : public FaceTypedBase { private: FaceTypedCylinder(); public: virtual bool isEqual(const TopoDS_Face &faceOne, const TopoDS_Face &faceTwo) const; virtual GeomAbs_SurfaceType getType() const; virtual TopoDS_Face buildFace(const FaceVectorType &faces) const; friend FaceTypedCylinder& getCylinderObject(); protected: virtual void boundarySplit(const FaceVectorType &facesIn, std::vector &boundariesOut) const; }; FaceTypedCylinder& getCylinderObject(); class FaceTypeSplitter { typedef std::map SplitMapType; public: FaceTypeSplitter(){} void addShell(const TopoDS_Shell &shellIn); void registerType(const GeomAbs_SurfaceType &type); bool hasType(const GeomAbs_SurfaceType &type) const; void split(); const FaceVectorType& getTypedFaceVector(const GeomAbs_SurfaceType &type) const; private: SplitMapType typeMap; TopoDS_Shell shell; }; class FaceAdjacencySplitter { public: FaceAdjacencySplitter(const TopoDS_Shell &shell); void split(const FaceVectorType &facesIn); std::size_t getGroupCount() const {return adjacencyArray.size();} const FaceVectorType& getGroup(const std::size_t &index) const {return adjacencyArray[index];} private: FaceAdjacencySplitter(){} void recursiveFind(const TopoDS_Face &face, FaceVectorType &outVector); std::vector adjacencyArray; TopTools_MapOfShape processedMap; TopTools_MapOfShape facesInMap; TopTools_IndexedDataMapOfShapeListOfShape faceToEdgeMap; TopTools_IndexedDataMapOfShapeListOfShape edgeToFaceMap; }; class FaceEqualitySplitter { public: FaceEqualitySplitter(){} void split(const FaceVectorType &faces, FaceTypedBase *object); std::size_t getGroupCount() const {return equalityVector.size();} const FaceVectorType& getGroup(const std::size_t &index) const {return equalityVector[index];} private: std::vector equalityVector; }; class FaceUniter { private: FaceUniter(){} public: FaceUniter(const TopoDS_Shell &shellIn); bool process(); const TopoDS_Shell& getShell() const {return workShell;} bool isModified(){return modifiedSignal;} const std::vector& getModifiedShapes() const {return modifiedShapes;} const ShapeVectorType& getDeletedShapes() const {return deletedShapes;} private: TopoDS_Shell workShell; std::vector typeObjects; std::vector modifiedShapes; ShapeVectorType deletedShapes; bool modifiedSignal; }; } /* excerpt from GeomAbs_SurfaceType.hxx enum GeomAbs_SurfaceType { GeomAbs_Plane, GeomAbs_Cylinder, GeomAbs_Cone, GeomAbs_Sphere, GeomAbs_Torus, GeomAbs_BezierSurface, GeomAbs_BSplineSurface, GeomAbs_SurfaceOfRevolution, GeomAbs_SurfaceOfExtrusion, GeomAbs_OffsetSurface, GeomAbs_OtherSurface }; */ namespace OCC { class BRepBuilderAPI_RefineModel : public BRepBuilderAPI_MakeShape { public: BRepBuilderAPI_RefineModel(const TopoDS_Shape&); void Build(); const TopTools_ListOfShape& Modified(const TopoDS_Shape& S); Standard_Boolean IsDeleted(const TopoDS_Shape& S); private: void LogModifications(const ModelRefine::FaceUniter& uniter); private: TopTools_DataMapOfShapeListOfShape myModified; TopTools_ListOfShape myEmptyList; TopTools_ListOfShape myDeleted; }; } #endif // MODELREFINE_H